ThreadPoolExecutor : Tasks are getting queued up and not submitted

后端 未结 6 1620
醉酒成梦
醉酒成梦 2021-02-03 11:42

We have a scenario where tasks submitted to ThreadPoolExecutor are long running. When the thread pool is started we start it with core pool size = 5, max pool size = 20 and queu

6条回答
  •  后悔当初
    2021-02-03 12:10

    The fundamental problem is that the user is really getting CORE_POOL_SIZE threads with unlimited Queue scenario. As such if there are 5 threads in core pool that's all he can ever use, max size does nothing to help. While reducing the time of thread execution is advisable in all cases, in production scenario we cannot often control how third party services will behave and as such the solution would be to increase core pool size to be equal to max pool size or limit the queue size.

提交回复
热议问题