标签:cells rup plist 安全性 rac edm read latch 读书
集合类型 | 非线程安全 | 线程安全 |
List | ArrayList | CopyOnWriteArrayList |
Set | SortedSet | ConcurrentSkipListSet |
Map | HashMap、SortedMap | ConcurrentHashMap、ConcurrentSkipListMap、 |
// 第一种方式 Thread thread = new Thread("interrupt test") { public void run() { for (;;) { doXXX(); if (Thread.interrupted()) { break; } } } }; thread.start(); // 另外一种方式 Thread thread = new Thread("interrupt test") { public void run() { for (;;) { try { doXXX(); } catch (InterruptedException e) { break; } catch (Exception e) { // handle Exception } } } }; thread.start(); // 第三种方式 public void foo() throws InterruptedException { if (Thread.interrupted()) { throw new InterruptedException(); } }
标签:cells rup plist 安全性 rac edm read latch 读书
原文地址:http://www.cnblogs.com/claireyuancy/p/6932001.html