ThreadPoolExecutor五种线程池状态(runState)

 

    RUNNING:      Accept new tasks and process queued tasks
    SHUTDOWN:     Don't accept new tasks, but process queued tasks
    STOP:         Don't accept new tasks, don't process queued tasks, and interrupt in-progress tasks
    TIDYING:      All tasks have terminated, workerCount is zero, the thread transitioning to state TIDYING will run the terminated() hook method
    TERMINATED: terminated() has completed



    private static final int COUNT_BITS = Integer.SIZE - 3;
    // runState is stored in the high-order bits
    private static final int RUNNING    = -1 << COUNT_BITS;
    private static final int SHUTDOWN   =  0 << COUNT_BITS;
    private static final int STOP       =  1 << COUNT_BITS;
    private static final int TIDYING    =  2 << COUNT_BITS;
    private static final int TERMINATED =  3 << COUNT_BITS;

 

posted @ 2023-06-14 09:59  码界小小学生  阅读(37)  评论(0编辑  收藏  举报