This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Using Threadlocal in a singleton class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Using Threadlocal in a singleton class" Watch "Using Threadlocal in a singleton class" New topic
Author

Using Threadlocal in a singleton class

Ryan Raina
Greenhorn

Joined: Jun 16, 2010
Posts: 28
hi all

I have a doubt regarding using thread local variables.. consider the following code



My first question is I want thread local present in the same class where rest of the methods are also present(On browsing internet everybody is making it in separate class and making thread local object in it ).....i want it in the same class(is the usage correct??)
My top level is singleton ..do I have any issue because of it..Also if threadlocal is static will it have any issue


Thanks in advance
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 5889
    
    6

Sorry, it's really not clear what you're asking. Can you try to clarify a bit? Maybe add some examples?

Also, please don't use large blocks of bold text. It's hard to read. Thanks!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Using Threadlocal in a singleton class
 
Similar Threads
Thread local
question about using localthread in hibernate?
java.text.Format is not thread-safe
Is accessing static class variables from non-static methods bad practice?
ThreadLocal & static