L
lightning
In javadoc:
Each thread holds an implicit reference to its copy of a thread-local
variable as long as the thread is alive and the ThreadLocal instance
is accessible; after a thread goes away, all of its copies of thread-
local instances are subject to garbage collection (unless other
references to these copies exist).
It seems only when thread "goes away",the threadlocals of that thread
will be cleaned.
But what about when using threadpools?
For example:
Executors.newFixedThreadPool()
In TOMCAT,the threadlocals works fine because framework such dwr ,
struts2 or spring transactionmanager using threadlocals to store many
things.How did it work?
Will it work fine no matter no matter Tomcat is using threadpool or
using singlethread mode?
Each thread holds an implicit reference to its copy of a thread-local
variable as long as the thread is alive and the ThreadLocal instance
is accessible; after a thread goes away, all of its copies of thread-
local instances are subject to garbage collection (unless other
references to these copies exist).
It seems only when thread "goes away",the threadlocals of that thread
will be cleaned.
But what about when using threadpools?
For example:
Executors.newFixedThreadPool()
In TOMCAT,the threadlocals works fine because framework such dwr ,
struts2 or spring transactionmanager using threadlocals to store many
things.How did it work?
Will it work fine no matter no matter Tomcat is using threadpool or
using singlethread mode?