Thread stop
程序员文章站
2022-04-01 16:12:29
...
public class Stop {
public static void main (String [] args) {
Slave s = new Slave();
s.start();
s.stop();
}
}
class Slave extends Thread {
@Override
public void run() {
try {
System.out.println("one");
Thread.sleep(2000);
System.out.println("two");
} catch (InterruptedException ex) {
ex.printStackTrace();
} catch (ThreadDeath death) {
death.printStackTrace();
}
}
}
Run java -server Stop
java.lang.ThreadDeath
at java.lang.Thread.stop(Thread.java:758)
at Stop.main(Stop.java:5)
No useful stack trace is printed.
推荐阅读
-
支持start,stop,restart的运行脚本
-
支持start,stop,restart的运行脚本
-
什么是线程调度器(Thread Scheduler)和时间分片(Time Slicing )?
-
Dont stop til you get enough php横向重复区域显示二法
-
Dont stop til you get enough PHP 输出缓存详解
-
MySQL Thread pool 操作过程
-
stop-and-remove-all-docker-containers-and-images
-
No Session found for current thread 咋解决?ehcache失效 咋解决?
-
python线程锁(thread)学习示例
-
jquery hover 不停闪动问题的解决方法(亦为stop()的使用)