Java基础进阶案例教程(课件)例7-2.docxVIP

  • 8
  • 0
  • 约小于1千字
  • 约 3页
  • 2018-12-28 发布于江西
  • 举报
class TestThreadInterrupt extends Thread{ public void run() { try { int i=1; while(i=100!Thread.currentThread().isInterrupted()){ System.out.print( +i); i++; Thread.sleep(500); } }catch(InterruptedException e) { System.out.println(e.toString()); }finally{ System.out.println(\n线程终止!); } } } public class Example7_2 { public static void main(String[] args) throws Exception { TestThreadInterrupt thread=new TestThreadInterrupt(); thread.start(); thread.sleep(5000); thread.interrupt(); } }

文档评论(0)

1亿VIP精品文档

相关文档