My limited understanding of ThreadLocal is that it has resource leak issues. I gather this problem can be remedied through proper use of WeakReferences with ThreadLocal (al
I realise this isn't strictly an answer to your question but as a general rule I won't suggest using a ThreadLocal
in situration where there isn't a clear tear down at the end of a request/interaction. The classic is doing this sort of thing in a servlet container, at first glance it seems fine, but since the threads are pooled it becomes a issue with the ThreadLocal
hanging onto the resource even after each request has been processed.
Suggestions: