首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

施用TreadPool时的ThreadLocal示例

2012-06-30 
使用TreadPool时的ThreadLocal示例转载,原文链接:http://www.cnblogs.com/goofy/archive/2011/11/11/22459

使用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());
}
?});
}
?}

热点排行