properties
private final BlockingQueue
private final ReentrantLock mainLock = new ReentrantLock();
private volatile long keepAliveTime;
private volatile boolean allowCoreThreadTimeOut;
private volatile int corePoolSize;
private volatile int maximumPoolSize;
private volatile int poolSize;
execute judgement
1 | public void execute(Runnable command) { |
thread judgement
1 | private boolean addIfUnderCorePoolSize(Runnable firstTask) { |
add thread
1 | private Thread addThread(Runnable firstTask) { |
Inner class Worker
1 | private final class Worker implements Runnable { |
get task from queue
1 | Runnable getTask() { |
the design of thread pool
Has no specific thread to dispatch task.
If still have task in QlockingQueue,
when thread’s task done, it will fetch task in queue itself.
If still no task in QlockingQueue, and task has done.
In worker’s run()
- workerDone(this);
call to terminate itself.
https://www.cnblogs.com/heyanan/p/9261695.html
http://www.cnblogs.com/dolphin0520/p/3932921.html