"Hi, Amigo!"
"We're going to start a more thorough exploration of threads."
"The concept of a thread group was introduced to prevent a thread from repeatedly stopping and interrupting every other thread. A thread can only affect other threads in the same thread group. ThreadGroup is a class for managing thread groups. This approach lets you protect threads from unwanted changes."
"Sometimes you have to run code that you can't fully trust. So it's convenient to put all of its threads in a separate group and block them from interfering with the work of the main thread group."
"A thread group can contain other groups. This lets you organize all your threads and groups in a hierarchical tree. In such a tree, each thread group (except the initial group) has its own parent."
"The ThreadGroup class has methods that let you get lists of all threads and affect/change them. When we create a new thread without explicitly specifying a group, it joins the same group as the creator thread."
"Here are some of the methods in the ThreadGroup class:"
Method | Description |
---|---|
|
Returns the group name |
|
Returns the parent group |
|
Interrupts all threads in the group. |
|
Checks whether the group is a daemon |
|
Sets the group's daemon property |
|
Returns the number of live threads in the group and its subgroups |
|
Returns the number of live groups in the group and its subgroups |
|
Puts all live threads into the array and returns the number of them. |
|
Returns the maximum priority for threads in the group. |
|
Lets you set the maximum priority of threads in the group and subgroups. |
GO TO FULL VERSION