欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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.
相关标签: thread Java

上一篇: 【凸包】

下一篇: 打印平行四边形