IntelliJ Java IDE
The moose likes Threads and Synchronization and the fly likes How to get a unique instance of a class for each thread? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "How to get a unique instance of a class for each thread?" Watch "How to get a unique instance of a class for each thread?" New topic
Author

How to get a unique instance of a class for each thread?

Ellen Zhao
Ranch Hand

Joined: Sep 17, 2002
Posts: 581
Say I have a class called Lsas. There will be exactly 6 threads to get a unique instance of Lsas for each. I've made the constructor private and provided a public static Lsas getLsas() method. Thanks in advance.

regards,
Ellen
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 23395

Look at the java.lang.ThreadLocal class. You could make your subclass of ThreadLocal an inner class of the class you're talking about, to give it access to the private constructor.


[Jess in Action][AskingGoodQuestions]
 
IntelliJ Java IDE
 
subject: How to get a unique instance of a class for each thread?
 
Threads others viewed
Mupltiple or single object(s) can be createdof a class: contradiction in this statement
Static reference varaible.
ClientID
instance as an object
RMI Basic Concepts 04
MyEclipse, The Clear Choice