7.5. Thread Groups

While threads can be created and run individually, sometimes it is easier to work with threads as a group, rather than one at a time. Operations that affect threads, such as suspending and resuming threads, stopping them cold, or interrupting them, can be performed on individual threads, but this requires developers to maintain a list of threads (using a data structure such as a vector or an array). When an operation must be performed, each and every thread in this list must be traversed and then acted upon. This creates extra work for developers by requiring more complex code. An easier alternative is to group threads together and apply an operation on the group rather than on the individual elements of the group.

The Java ...

Get Java™ Network Programming and Distributed Computing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.