摘要: synchronized 关键字的意思,执行方法的时候,当前对象被锁定下面的示例要对访问b的所有函数要加synchronized ,否则其他调用者会篡改b的值public class TT implements Runnable { int b = 100; public synchroniz... 阅读全文
posted @ 2015-08-30 13:04 太阳星辰 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 当线程的run方法结束,线程就结束了,结束一个正在运行的线程,怎么实现呢,示例如下public class TestThread4 { public static void main(String args[]) { Runner4 r = new Runner4(); Thread... 阅读全文
posted @ 2015-08-30 12:22 太阳星辰 阅读(179) 评论(0) 推荐(0) 编辑