使用TreadPool时的ThreadLocal示例
转载,原文链接:http://www.cnblogs.com/goofy/archive/2011/11/11/2245907.html
?
???public voidset(T value) {
???????Thread t = Thread.currentThread();
???????ThreadLocalMap map = getMap(t);
???????if (map!= null)
???????????map.set(this, value);
???????else
???????????createMap(t, value);
}
?}?});
?
//没有set的Runnable
?pool.execute(new Runnable() {
?@Override
public void run() {
System.out.println("" + Thread.currentThread() + "not seted bol:" + bol.get());
}
?});
}
?}