Originally posted by jacob deiter:
Advantage of Threadlocal over session object in web application. I can save all data related to particular user in Session object or Threadlocal ?.
[ October 15, 2008: Message edited by: jacob deiter ]
Both could be used as data holders, but are drastically different coming to visibility/scope.
ThreadLocal is specific to a thread - meaning whatever info you put in here is not visible/accessible from other threads. On the other hand data kept in a Session is accessible to all threads part of that session.
If you need to manage some data, which you can not have as local variables then ThreadLocal is the way to go.