标签:edit idt style 线程的状态 自动 ons 简单的 关系 inter
 
2、interrupted 和 isInterrupted
| 1 | publicstaticbooleaninterrupted
 () { | 
| 2 |      returncurrentThread().isInterrupted(true); | 
| 3 | } | 
| 1 | publicbooleanisInterrupted
 () { | 
| 2 |      returnisInterrupted( false); | 
| 3 | } | 
| 1 | privatenativebooleanisInterrupted( booleanClearInterrupted); | 
如果这个参数为true,说明返回线程的状态位后,要清掉原来的状态位(恢复成原来情况)。这个参数为false,就是直接返回线程的状态位。
这两个方法很好区分,只有当前线程才能清除自己的中断位(对应interrupted()方法)
是不是这样理解呢,
Thread.currentThread().interrupt(); 这个用于清除中断状态,这样下次调用Thread.interrupted()方法时就会一直返回为false,因为中断标志已经被恢复了。
而调用isInterrupted 只是简单的查询中断状态,不会对状态进行修改。
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow
interrupt interrupted isInterrupted 区别
标签:edit idt style 线程的状态 自动 ons 简单的 关系 inter
原文地址:https://www.cnblogs.com/skinchqqhah/p/10350213.html