2011年10月6日
摘要: 代码如下,比较坑爹,就是上一篇文章的hashmap改为了ThreadLocalpublic class ThreadScopeShareData { /** * @param args */// private static HashMap<Thread, Integer> map = new HashMap<Thread, Integer>(); private static ThreadLocal<Integer> threadLocal = new ThreadLocal<Integer>(); public static void mai 阅读全文
posted @ 2011-10-06 20:04 victorlinwen 阅读(502) 评论(0) 推荐(1)
摘要: public class ThreadScopeShareData { /** * @param args */ private static HashMap<Thread, Integer> map = new HashMap<Thread, Integer>(); public static void main(String[] args) { for(int i=0;i<2;i++){ new Thread(new Runnable() { @Override public void run() { int data = new Random().nextI 阅读全文
posted @ 2011-10-06 11:00 victorlinwen 阅读(1215) 评论(0) 推荐(0)