users@glassfish.java.net

ThreadLocals in request threads

From: Motling, Premraj <motling_at_optymyze.com>
Date: Fri, 21 Mar 2014 10:04:25 -0400

What happens when there is an exception in request thread? Does it go to pool or just die?

Background -
I'm using ThreadLocal in my application and at one point (say A) I populate some values and at another point (say B) use those values for some decision making and then clear those values. I'm more interested in what will happen if something happens (say exception or anything) and I couldn't clear those values from ThreadLocal. Since same thread may go pool again causing issues in future?

But this seems like very basic problem to me and then ThreadLocals cannot be used at all - so just wanted to confirm whether I'm missing anything here?

- Premraj.