Source code analysis, how to quickly use ThreadPoolExecutor

The atomic CTL variable uses the control status, it has two functions, and records the number of workers and the running status (the lower 29 bits are the number of workers and the upper three bits are the running status). Its initial value is RUNNING (111 00000000000000000000000000000), remember that this is a negative number, the maximum value is 0, so there is an isRunning method to determine whether it is running: ctl.get () <SHUTDOWN (0). The thread pool encapsulates the created job thread into a worker class, which completes the Runnable interface and also inherits AQS (row and column synchronizer). The purpose is to ensure that when only one thread gets the current thread when multiple threads call the thread pool to perform tasks. lock.

Guess you like

Origin www.cnblogs.com/selang/p/12709973.html