The moose likes Threads and Synchronization and the fly likes Thread Question: Are they all Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread Question: Are they all "under" creator?" Watch "Thread Question: Are they all "under" creator?" New topic

Thread Question: Are they all "under" creator?

Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
If I start an application in a Thread, and that application starts a bunch of threads (and those threads may also, etc):
1. Can I control those threads in any way?
2. Can i grab/attach to/find those threads?
3. Are all those threads under the first thread I started?
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Moving to Threads.

"JavaRanch, where the deer and the Certified play" - David O'Meara
Robert Paris
Ranch Hand

Joined: Jul 28, 2002
Posts: 585
Cindy! You are always moving my threads but never answering them!
OK, here's the answer: yes, but...
What you'll need to do is add security to make sure they don't have permission to add the thread to the main threadgroup or any other group you don't want them to add to. That way, you guarantee they're under a certain group. Also, if I create a ThreadGroup and a thread under it which creates other threads which create threadgroups and more threads under thos, then if you call:
mainThreadGroup.parentOf( threadFourLevelsDown );
it will return true. That method should be called ancestorOf() not parent of, because both are true.
jQuery in Action, 2nd edition
subject: Thread Question: Are they all "under" creator?
Similar Threads
Running multiple Threads for a long time
Will a started thread run to completion in this example?
Thread stuck problems - StuckThreadMaxTime exceeded
Getting number of active threads and open sockets
looking for help about using multiple threads to process several objects