I am wondering why there is so little documentation about Thread Groups on the internet ? Are they still used or they are some stale concepts ? Can some one explain:
What they are.
What they are used for.
If they are stilled used, where ?
Give some real application examples (web servers like, maybe).
They are used as a Group of Threads. In a simple application you only need one, but in a more complex application server it makes sense to have one for each application.
why there is so little documentation about Thread Groups on the internet ?
I guess some assume it's a pretty simple idea. Not sure what is missing about it.
Are they still used or they are some stale concept ?
I would image most developers never think about Thread Groups. But I think they are useful in certain situations. We have a library where we have a custom ThreadGroup for resetting thread affinity.
Can some one explain that are they what they are used for, if still used, and give an example.
Mostly in applications servers, each server has it's own collection of threads and can be managed collectively. If you want to monitor or shutdown an application your need to know which threads the application started.
If you start off a thread in a ThreadGroup, every Thread it creates will also be in that thread group. Without this feature, you would have a hard time assigning threads to applications.
From @biziclop: How do you reliably enumerate threads in a group?
You can get the size of activeThreads and enumerate as the ThreadGroup locks on this
(for better or worse)
synchronized(threadGroup) {
Thread[] threads = threadGroup.activeCount();
threadGroup.enumerate(threads);
// use threads before the lock is released or it could be wrong.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With