posted 11 years ago
Here is what I think. Consider the cost of synchronization--the cost of performing an synchronized operation is 100 times slower that the one that does not need to synchronize. According to the InitialContext's API,
Since web tier ServiceLocator uses singleton, a single InitialContext instance is concurrently accessed by multiple threads. Being in the same box with other ejb beans, EJB tier Servicelocator doesn't use singleton to avoid synchronization. Please, comment?An InitialContext instance is not synchronized against concurrent access by multiple threads. Multiple threads each manipulating a different InitialContext instance need not synchronize. Threads that need to access a single InitialContext instance concurrently should synchronize amongst themselves and provide the necessary locking.