Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

When does a thread in Spring ThreadPoolTaskExecutor queue get into running state?

I am using core pool size of 3 and queue size of 50 and max pool size of 500.

Suppose core pool and queue has threads as following

core pool = [A, B, C]
queue = [D, E, F]

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Will the thread D execute only after one of the treads in core pool finishes execution?
or

Can a running thread say B in core pool go in waiting state and thread D gets pulled into core pool?

>Solution :

One of A,B, or C tasks has to finish before the pool can start another task. Each task runs to completion or until canceled, going into a wait state doesn’t free up the worker thread.

Here is the openjdk code for the ThreadPoolExecutor: http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/util/concurrent/ThreadPoolExecutor.java. There is a runWorker method that gets the next task and calls run on it (line 1141).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading