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
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.