简体   繁体   English

异步Web服务Jersey中的newFixedThreadPool

[英]newFixedThreadPool in asynchronous web services Jersey

Hello I tried to create a async web services following a tutorial. 您好,我尝试按照教程创建异步Web服务。 I'm not understand this statement: 我不明白这句话:

service = MoreExecutors.listeningDecorator ( Executors.newFixedThreadPool (10) ) ; 服务= MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));

What does that mean ? 这意味着什么 ? I can have 10 simultaneous requests ? 我可以同时有10个请求吗?

because I wanted to know when they get so many simultaneous requests as he works async web services ? 因为我想知道当他工作异步Web服务时何时收到这么多同时请求? there is a queue ? 有排队吗?

Yes, you understand correctly, it means that there is a pool of 10 parallel threads that handles the requests. 是的,您理解正确,这意味着存在一个由10个并行线程组成的池来处理请求。 Usually there is 1 acceptor that takes the request and forward it to a handler (one of the 10 threads). 通常,有1个接受者接受请求并将其转发到处理程序(10个线程之一)。

But, it doesnt mean that if you will have 100 requests they will be rejected. 但是,这并不意味着如果您有100个请求,它们将被拒绝。 it just will take longer since they will go into the ThreadPool queue and wait untill there is a free thread to handle them 这将花费更长的时间,因为它们将进入ThreadPool队列并等待直到有空闲线程来处理它们

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM