ExecutorService, standard way to avoid to task queue getting too full

后端 未结 5 1895
死守一世寂寞
死守一世寂寞 2021-01-31 16:36

I am using ExecutorService for ease of concurrent multithreaded program. Take following code:

while(xxx) {
    ExecutorService exService = Executors         


        
5条回答
  •  青春惊慌失措
    2021-01-31 16:53

    A true blocking ThreadPoolExecutor has been on the wishlist of many, there's even a JDC bug opened on it. I'm facing the same problem, and came across this: http://today.java.net/pub/a/today/2008/10/23/creating-a-notifying-blocking-thread-pool-executor.html

    It's an implementation of a BlockingThreadPoolExecutor, implemented using a RejectionPolicy that uses offer to add the task to the queue, waiting for the queue to have room. It looks good.

提交回复
热议问题