为什么不用stop()
http://www.cnblogs.com/greta/p/5624839.html
http://yeziwang.iteye.com/blog/844649
stop会在任何时刻抛出ThreadDeath异常并且释放了它所占有的锁,而此时程序猿没做任何准备
多数用
synchronized (lock) {
if(stop)
return;
......
}
或者
try {
synchronized (lock) {
while(true){
Thread.sleep(1000);
xxxxxxxxxxxx
}
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
在sleep的时候别人调用interrupt中断线程