- 区别1,interrupted()属于类方法,而interrupt()和isInterrupted()属于对象方法。
- 区别2:
- interrupted():返回当前线程的中断标志位,并设置中断标志位false;
- interrupt():设置线程对象的中断标志位为true;
- isInterrupted():返回线程对象的中断标志位。
- 关于,当线程满足两个条件,阻塞状态和中断标志为ture,则会抛出InterruptedException异常,并且会自动将中断标志位设置为false,阻塞方法,一般有,Thread.sleep(…),Object.wait(…),join(…),中断不会停止线程。
interrupt()、interrupted()、isInterrupted() 的区别
猜你喜欢
转载自blog.csdn.net/INK_FUNC/article/details/88191597
今日推荐
周排行