A DESCRIPTION OF THE REQUEST :
Threads are often reused rather than destroyed and recreated, e.g. in a Thread pooled server. In that case, it would be nice, even necessary, to be able to clear out all ThreadLocalS that were set during the previous use of the Thread so that the Thread is reset to its first-created state. This could be a clearThreadLocals() method on a Thread instance or a static clearAll() method on ThreadLocal class.
JUSTIFICATION :
When a Thread is reused by a framework the intent is for it to be as if the Thread were just created. ThreadLocalS should not be left over from the previous use of the Thread.
Whether or not this type of Thread reuse is a good idea or not, it is in wide use and Java should provide a way to accomodate this usage.
CUSTOMER SUBMITTED WORKAROUND :
The only partial workaround is to manually keep track of all ThreadLocals used and set them to null or remove them at the end of the Thread use. This is obviously not optimal, and in many cases, not possible.
###@###.### 2005-04-29 06:28:34 GMT
Threads are often reused rather than destroyed and recreated, e.g. in a Thread pooled server. In that case, it would be nice, even necessary, to be able to clear out all ThreadLocalS that were set during the previous use of the Thread so that the Thread is reset to its first-created state. This could be a clearThreadLocals() method on a Thread instance or a static clearAll() method on ThreadLocal class.
JUSTIFICATION :
When a Thread is reused by a framework the intent is for it to be as if the Thread were just created. ThreadLocalS should not be left over from the previous use of the Thread.
Whether or not this type of Thread reuse is a good idea or not, it is in wide use and Java should provide a way to accomodate this usage.
CUSTOMER SUBMITTED WORKAROUND :
The only partial workaround is to manually keep track of all ThreadLocals used and set them to null or remove them at the end of the Thread use. This is obviously not optimal, and in many cases, not possible.
###@###.### 2005-04-29 06:28:34 GMT