| 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]
|
 |
 |
|
|
subject: How to get a unique instance of a class for each thread?
|
|
|