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
You can find all active threads using ThreadGroup:
ThreadGroup.getParent()
until you find a group with a null parent.ThreadGroup.enumerate()
to find all threads on the system.The value of doing this completely escapes me ... what will you possibly do with a named thread? Unless you're subclassing Thread
when you should be implementing Runnable
(which is sloppy programming to start with).