This content has been marked as final. Show 2 replies
You are right, there is no guarantee that a particular thread will be used by a particular ejb or servlet. So threadlocals should not be used. Even if container picks up the same thread to run the ejb, in a highly available/clustered environment, request may land up in different JVMs, so process wide synchronisation won't suffice.
Refer to section #25.1.2 of EJB 2.1 spec where some programming restrictions for EJB are mentioned. You may also refer to In J2EE platform spec where security permissions for different containers are mentioned.
Hi to all,
ThreadLocal is simply used for only naming to thread Object that'why ThreadLocals are implemented using a Map attached to each Thread instance, so their values will disappear when the Thread is no longer used and garbage collected.
And Garbage collector is dedicated to JVM.so you ca'nt depeond on this type of coding.
Message was edited by: