Ai
1 Star 0 Fork 0

抽离。/ConcurrentTest

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
InterruptTest.java 787 Bytes
一键复制 编辑 原始数据 按行查看 历史
抽离。 提交于 2018-09-28 23:02 +08:00 . init
public class InterruptTest {
public static void main(String[] args) throws Exception{
Thread thread = new Thread() {
@Override
public void run() {
long i = 1L;
while (true) {
if (Thread.currentThread().isInterrupted()) {
System.out.println("Interruted!");
break;
}
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println(i++);
}
}
};
thread.start();
Thread.sleep(2000);
thread.interrupt();
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/asmysoul/ConcurrentTest.git
git@gitee.com:asmysoul/ConcurrentTest.git
asmysoul
ConcurrentTest
ConcurrentTest
master

搜索帮助