package com.xiaojiezhu.thread; /** * @author xiaojie.zhu */ public class ThreadBreak4 implements Runnable { @Override public void run() { System.out.println("进入线程"); try { Thread.sleep(20000); System.out.println("结束线程"); } catch (InterruptedException e) { e.printStackTrace(); } } public static void main(String[] args) { Thread t = new Thread(new ThreadBreak4()); t.start(); try { Thread.sleep(200); t.stop(); System.out.println("over"); } catch (InterruptedException e) { e.printStackTrace(); } } }
打印结果如下
进入线程
over
您可能感兴趣的文章: