In a webapp, I have a scenario where I need some kind of global context (Static like) for few variables, for the current thread only.
If there are 3 different concurrent users, then I expect three corresponding global context variable for the 3 separate threads/sessions.
Using a Static variable makes its scope global for all the threads.
Is there a way in which I can achieve this?
6
A ThreadLocal
is what you want. However, in your situation, I think that you should go for Session
scoped variables.