线程池有哪些状态?

线程池有哪些状态?

线程池的5种状态:RUNNING、SHUTDOWN、STOP、TIDYING、TERMINATED。

见 ThreadPoolExecutor 源码

// 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;

 

状态转换可参考:

https://blog.csdn.net/shahuhubao/article/details/80311992 

 


专栏:

  • 自做 Java 面试题

  • 重学 Java 并发编程

写了微信小程序汇总Java 面试题

线程池有哪些状态?_第1张图片

每天持续更新中.......

 

你可能感兴趣的:(自做,Java,面试题)