线程中断
2014-07-03 20:41
134 查看
ublic class Main { public static void main(String[] args) throws InterruptedException { Test test=new Test(); test.start(); Thread.sleep(2000); //中断线程 test.interrupt(); } static class Test extends Thread{ @Override public void run() { for (int i = 0; i <Integer.MAX_VALUE; i++) { System.out.println("---------->i"); //中断线程 if (isInterrupted()) { System.out.println("........中断线程"); return ; } /*if (Thread.interrupted()) { try { throw new InterruptedException(); } catch (InterruptedException e) { System.out.println("........线程中断"); } }*/ } } } }
相关文章推荐
- Java 线程的中断机制
- java线程中断[interrupt()函数]
- 如何中断线程in Java
- 线程中断、线程让步、线程睡眠、线程合并
- Java怎样中断一个运行中的线程
- Thread线程中断相关方法
- LockSupport的park和unpark的基本使用,以及对线程中断的响应性
- 中断优先级和中断线程优先级
- 如何中断“同步/阻塞”线程,not only interrupt()
- 中断JAVA线程
- JAVA线程的中断
- 线程中CreateEvent和SetEvent及WaitForSingleObject的用法-------wince里面的中断IST经常使用。
- WinCE--中断服务线程IST(详解)
- 【Java并发编程】之二:线程中断(含代码)
- 线程中CreateEvent和SetEvent及WaitForSingleObject的用法-------wince里面的中断IST经常使用。 .
- 中断线程
- 进程与线程,内存管理及中断
- Thread类之线程中断
- 【Boost】boost库中thread多线程详解11——线程的休眠和中断
- 关于线程的中断机制