2,threadgroup Concepts and usage

Source: Internet
Author: User

When a task requires more than one child thread to handle the business, it is not desirable that these sub-threads be disorganized, and the thread groups are created when they need to be managed uniformly.

Threadgroup API description, where red is the common method

Method Summary
     int activeCount()
Returns the estimated number of active threads in this thread group.
     int activeGroupCount()
Returns the estimated number of active thread groups in this thread group.
boolean allowThreadSuspension(boolean b)
is obsolete. The definition of this call depends on suspend (), which is deprecated. Further, the behavior of this call is never specified.
 void checkAccess()
Determines whether the currently running thread has permission to modify this thread group.
 void destroy()
Destroys this thread group and all its child groups.
 int enumerate(Thread[] list)
Copies all active threads in this thread group and its subgroups into the specified array.
 int enumerate(Thread[] list, boolean recurse)
Copies all the active threads in this thread group into the specified array.
 int enumerate(ThreadGroup[] list)
Copies a reference to all active subgroups in this thread group into the specified array.
 int enumerate(ThreadGroup[] list, boolean recurse)
Copies a reference to all active subgroups in this thread group into the specified array.
 int getMaxPriority()
Returns the highest priority for this thread group.
 String getName()
Returns the name of this thread group.
 ThreadGroup getParent()
Returns the parent thread group for this thread group.
 void interrupt()
Interrupts all threads in this thread group.
 boolean isDaemon()
Tests whether this thread group is a background program thread group.
 boolean isDestroyed()
Tests whether this thread group has been destroyed.
 void list()
Prints information about this thread group to standard output.
 boolean parentOf(ThreadGroup g)
Tests whether this thread group is a thread group parameter or one of its ancestor thread groups.
 void resume()
is obsolete. This method is only used for federated Thread.Suspend and threadgroup.suspend , because they are inherently prone to deadlocks, so both are deprecated. For more information, see Thread.Suspend ().
 void setDaemon(boolean daemon)
Change the background program state for this thread group.
 void setMaxPriority(int pri)
Sets the highest priority for the thread group.
 void stop()
is obsolete. This method has inherent insecurity. For more information, see Thread.stop ().
 void suspend()
is obsolete. This method easily leads to deadlocks. For more information, see Thread.Suspend ().
 String toString()
Returns a string representation of this thread group.
 void uncaughtException(Thread t, Throwable e)
This method is called by Java Virtual Machine when a thread in this thread group stops because of an uncaught exception and the thread does not have a specific thread.uncaughtexceptionhandler installed.

2,threadgroup Concepts and usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.