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

后端 未结 5 1858
死守一世寂寞
死守一世寂寞 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:51

    you can add another bloquing queue that's has limited size to controle the size of internal queue in executorService, some thinks like semaphore but very easy. before executor you put() and whene the task achive take(). take() must be inside the task code

提交回复
热议问题