2014年5月26日
摘要: AtomicInteger原子操作实现同步 package Thread.Common; import java.util.Timer; import java.util.TimerTask; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; 阅读全文
posted @ 2014-05-26 23:16 上校 阅读(6609) 评论(0) 推荐(0)
摘要: 数据类: package Thread.MyCommon; public class Data { public int num = 0; public synchronized int getEven() { ++num; Thread.yield();//让另外线程先执行,加大测试效果几率 ++num; return num; } } 阅读全文
posted @ 2014-05-26 21:06 上校 阅读(8849) 评论(0) 推荐(0)