zzh

zzh

Partial analysis of Executors.newCachedThreadPool

Basic Composition#

image
From the above image, it can be seen that newCachedThreadPool is composed of 0 core threads + Integer.MAX_VALUE maximum threads + SynchronousQueue blocking queue (where each thread has a maximum survival time of 60s).

Execution Process#

image
For the SynchronousQueue blocking queue, since this blocking queue can only offer an object when taking, the red box section will return false and cannot enter. At this point, it will enter the green box section for judgment (at this time, a regular thread will be started and the corresponding command will be executed using the regular thread).

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.