When specifying a separate kernel and maximum pool size in ThreadPoolExecutor, is it a good idea?

I am trying to understand the essence of determining the size of the kernel and the maximum pool for Java 5 ThreadPoolExecutor. I understand that the number of threads increases only after the queue is full, which seems a bit late (at least with large queues).

Is it not that I am happy to allocate more threads for tasks, in which case I can simply increase the size of the kernel pool; or I really donโ€™t want to do this, and in this case I should have a big queue? What is the scenario in which the individual kernel sizes and maximum pool are useful?

+5
source share
2 answers

It is discussed here.

The pool is designed to work under normal load on corePoolSize (to which it builds up if a preliminary start is not used). When an overload condition occurs (determined by the fact that there is more waiting / in the process of the task than the employees), we use the queue to work as a buffer - using the expectation that the normal workload will be restored in the near future. If we are concerned about excessive congestion, we can use a limited queue, and that "if the queue is full, add more workers to maxPoolSize." If we use an unlimited queue, we say that we do not expect (or worry) excessive congestion.

, , , (.. - ).

+4

, , . , , , .

, , , (, -). , , , , , .

, -, , . , , .

+2

All Articles