I have a multithreaded application and I assign a unique name to each thread through setName() property. Now, I want functionality to get access to the threads
I like the HashMap idea best, but if you want to keep the Set, you can iterate over the Set, rather than going through the setup of converting to an array:
Iterator i = threadSet.iterator();
while(i.hasNext()) {
Thread t = i.next();
if(t.getName().equals(threadName)) return t;
}
return null;