5 states thread pool

1.Running: accept the new task, the processing task waiting;

2.ShutDown: do not accept the new task, but the processing task waiting;

3.Stop: do not accept the new task, do not wait for the processing task, try to interrupt task is being executed;

4.Tidying: but all task are terminated, worCount == 0 time (workCount is the effective number of threads);

5.Terminated: End execution terminated () method;

 

Running -> ShutDown:

  Performing the shutdown ();

Running or ShutDown --> Stop:

  Performing shutdownNow ();

 

Stop --> Tidying

  When the pool is empty

ShutDown --> Tidying

  When the queue is empty and pool

 

Tidying -->  Terminated

  When the terminated () method;

 

Guess you like

Origin www.cnblogs.com/noino/p/11265000.html