ThreadPoolExecutor source of parsing thread pool

1. Variables

ThreadPoolExecutor first defines these constants, and a look ignorant force at first glance, in fact it is a binary high three int to represent the state of the thread pool,

First look at bit computing:

  1. << 'left: right side up position vacated 0, which corresponds to the value multiplied by two.
  2. '>>' right: left vacated position, if it is positive then filled with a zero if it is negative, then fill 0 or 1, depending on the computer system used in OS X S.1. It corresponds to the value divided by two.
  3. By the absolute value of its negative binary negated after adding 1
    Final CTL of AtomicInteger = new new Private of AtomicInteger (ctlOf (the RUNNING, 0)); 
    Private static int COUNT_BITS Final Integer.SIZE = -. 3; 29 // 
    Private in CAPACITY static int = Final (COUNT_BITS <<. 1) -. 1; //. 1 < <29 = 00000000 00000000 0,010,000,000,000,000 minus 1 = 0,001,111,111,111,111 1,111,111,111,111,111 
   binary 1 // 001, 110 is negated, 111, 111 plus 1 binary is -1, then left 29, 
    Private static int the RUNNING = Final << COUNT_BITS -1; // 111 00000 00000000 00000000 00000000 
    Private Final static int = 0 << COUNT_BITS the SHUTDOWN; // 000 00000 00000000 00000000 00000000 
    Private Final static int. 1 << COUNT_BITS the STOP =; // 001 00000 00000000 00000000 00000000
    private static final int TIDYING    =  2 << COUNT_BITS;// 01000000 00000000 00000000 00000000
    private static final int TERMINATED =  3 << COUNT_BITS;// 01100000 00000000 00000000 00000000

  

Guess you like

Origin www.cnblogs.com/akaneblog/p/11462549.html