Java Doc for ThreadGroup.java in  » 6.0-JDK-Core » lang » java » lang » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » lang » java.lang 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.lang.ThreadGroup

ThreadGroup
public class ThreadGroup implements Thread.UncaughtExceptionHandler(Code)
A thread group represents a set of threads. In addition, a thread group can also include other thread groups. The thread groups form a tree in which every thread group except the initial thread group has a parent.

A thread is allowed to access information about its own thread group, but not to access information about its thread group's parent thread group or any other thread groups.
author:
   unascribed
version:
   1.73, 06/27/07
since:
   JDK1.0



Field Summary
 booleandaemon
    
 booleandestroyed
    
 ThreadGroupgroups
    
 intmaxPriority
    
 intnUnstartedThreads
    
 Stringname
    
 intngroups
    
 intnthreads
    
 ThreadGroupparent
    
 Threadthreads
    
 booleanvmAllowSuspension
    

Constructor Summary
public  ThreadGroup(String name)
     Constructs a new thread group.
public  ThreadGroup(ThreadGroup parent, String name)
     Creates a new thread group.

Method Summary
public  intactiveCount()
     Returns an estimate of the number of active threads in this thread group.
public  intactiveGroupCount()
     Returns an estimate of the number of active groups in this thread group.
 voidadd(Thread t)
     Adds the specified Thread to this group.
 voidaddUnstarted()
     Increments the count of unstarted threads in the thread group.
public  booleanallowThreadSuspension(boolean b)
     Used by VM to control lowmem implicit suspension.
final public  voidcheckAccess()
     Determines if the currently running thread has permission to modify this thread group.
final public  voiddestroy()
     Destroys this thread group and all of its subgroups.
public  intenumerate(Thread list)
     Copies into the specified array every active thread in this thread group and its subgroups.
public  intenumerate(Thread list, boolean recurse)
     Copies into the specified array every active thread in this thread group.
public  intenumerate(ThreadGroup list)
     Copies into the specified array references to every active subgroup in this thread group.
public  intenumerate(ThreadGroup list, boolean recurse)
     Copies into the specified array references to every active subgroup in this thread group.
final public  intgetMaxPriority()
     Returns the maximum priority of this thread group.
final public  StringgetName()
     Returns the name of this thread group.
final public  ThreadGroupgetParent()
     Returns the parent of this thread group.

First, if the parent is not null, the checkAccess method of the parent thread group is called with no arguments; this may result in a security exception.

final public  voidinterrupt()
     Interrupts all threads in this thread group.

First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

final public  booleanisDaemon()
     Tests if this thread group is a daemon thread group.
public synchronized  booleanisDestroyed()
     Tests if this thread group has been destroyed.
public  voidlist()
     Prints information about this thread group to the standard output.
 voidlist(PrintStream out, int indent)
    
final public  booleanparentOf(ThreadGroup g)
     Tests if this thread group is either the thread group argument or one of its ancestor thread groups.
 voidremove(Thread t)
     Removes the specified Thread from this group.
final public  voidresume()
     Resumes all threads in this thread group.

First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

final public  voidsetDaemon(boolean daemon)
     Changes the daemon status of this thread group.

First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

final public  voidsetMaxPriority(int pri)
     Sets the maximum priority of the group.
final public  voidstop()
     Stops all threads in this thread group.

First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

final public  voidsuspend()
     Suspends all threads in this thread group.

First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

public  StringtoString()
     Returns a string representation of this Thread group.
public  voiduncaughtException(Thread t, Throwable e)
     Called by the 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.

The uncaughtException method of ThreadGroup does the following:

  • If this thread group has a parent thread group, the uncaughtException method of that parent is called with the same two arguments.

Field Detail
daemon
boolean daemon(Code)



destroyed
boolean destroyed(Code)



groups
ThreadGroup groups(Code)



maxPriority
int maxPriority(Code)



nUnstartedThreads
int nUnstartedThreads(Code)



name
String name(Code)



ngroups
int ngroups(Code)



nthreads
int nthreads(Code)



parent
ThreadGroup parent(Code)



threads
Thread threads(Code)



vmAllowSuspension
boolean vmAllowSuspension(Code)




Constructor Detail
ThreadGroup
public ThreadGroup(String name)(Code)
Constructs a new thread group. The parent of this new group is the thread group of the currently running thread.

The checkAccess method of the parent thread group is called with no arguments; this may result in a security exception.
Parameters:
  name - the name of the new thread group.
exception:
  SecurityException - if the current thread cannot create athread in the specified thread group.
See Also:   java.lang.ThreadGroup.checkAccess
since:
   JDK1.0




ThreadGroup
public ThreadGroup(ThreadGroup parent, String name)(Code)
Creates a new thread group. The parent of this new group is the specified thread group.

The checkAccess method of the parent thread group is called with no arguments; this may result in a security exception.
Parameters:
  parent - the parent thread group.
Parameters:
  name - the name of the new thread group.
exception:
  NullPointerException - if the thread group argument isnull.
exception:
  SecurityException - if the current thread cannot create athread in the specified thread group.
See Also:   java.lang.SecurityException
See Also:   java.lang.ThreadGroup.checkAccess
since:
   JDK1.0





Method Detail
activeCount
public int activeCount()(Code)
Returns an estimate of the number of active threads in this thread group. The result might not reflect concurrent activity, and might be affected by the presence of certain system threads.

Due to the inherently imprecise nature of the result, it is recommended that this method only be used for informational purposes. an estimate of the number of active threads in this threadgroup and in any other thread group that has this threadgroup as an ancestor.
since:
   JDK1.0




activeGroupCount
public int activeGroupCount()(Code)
Returns an estimate of the number of active groups in this thread group. The result might not reflect concurrent activity.

Due to the inherently imprecise nature of the result, it is recommended that this method only be used for informational purposes. the number of active thread groups with this thread group asan ancestor.
since:
   JDK1.0




add
void add(Thread t)(Code)
Adds the specified Thread to this group.
Parameters:
  t - the Thread to be added
exception:
  IllegalThreadStateException - If the Thread group has been destroyed.



addUnstarted
void addUnstarted()(Code)
Increments the count of unstarted threads in the thread group. Unstarted threads are not added to the thread group so that they can be collected if they are never started, but they must be counted so that daemon thread groups with unstarted threads in them are not destroyed.



allowThreadSuspension
public boolean allowThreadSuspension(boolean b)(Code)
Used by VM to control lowmem implicit suspension.
Parameters:
  b - boolean to allow or disallow suspension true on success
since:
   JDK1.1ThreadGroup.suspend



checkAccess
final public void checkAccess()(Code)
Determines if the currently running thread has permission to modify this thread group.

If there is a security manager, its checkAccess method is called with this thread group as its argument. This may result in throwing a SecurityException.
exception:
  SecurityException - if the current thread is not allowed toaccess this thread group.
See Also:   java.lang.SecurityManager.checkAccess(java.lang.ThreadGroup)
since:
   JDK1.0




destroy
final public void destroy()(Code)
Destroys this thread group and all of its subgroups. This thread group must be empty, indicating that all threads that had been in this thread group have since stopped.

First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.
exception:
  IllegalThreadStateException - if the thread group is notempty or if the thread group has already been destroyed.
exception:
  SecurityException - if the current thread cannot modify thisthread group.
See Also:   java.lang.ThreadGroup.checkAccess
since:
   JDK1.0




enumerate
public int enumerate(Thread list)(Code)
Copies into the specified array every active thread in this thread group and its subgroups.

First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

An application might use the activeCount method to get an estimate of how big the array should be, however if the array is too short to hold all the threads, the extra threads are silently ignored. If it is critical to obtain every active thread in this thread group and its subgroups, the caller should verify that the returned int value is strictly less than the length of list.

Due to the inherent race condition in this method, it is recommended that the method only be used for informational purposes.
Parameters:
  list - an array into which to place the list of threads. the number of threads put into the array.
exception:
  SecurityException - if the current thread does nothave permission to enumerate this thread group.
See Also:   java.lang.ThreadGroup.activeCount
See Also:   java.lang.ThreadGroup.checkAccess
since:
   JDK1.0




enumerate
public int enumerate(Thread list, boolean recurse)(Code)
Copies into the specified array every active thread in this thread group. If the recurse flag is true, references to every active thread in this thread's subgroups are also included. If the array is too short to hold all the threads, the extra threads are silently ignored.

First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

An application might use the activeCount method to get an estimate of how big the array should be, however if the array is too short to hold all the threads, the extra threads are silently ignored. If it is critical to obtain every active thread in this thread group, the caller should verify that the returned int value is strictly less than the length of list.

Due to the inherent race condition in this method, it is recommended that the method only be used for informational purposes.
Parameters:
  list - an array into which to place the list of threads.
Parameters:
  recurse - a flag indicating whether also to include threadsin thread groups that are subgroups of thisthread group. the number of threads placed into the array.
exception:
  SecurityException - if the current thread does nothave permission to enumerate this thread group.
See Also:   java.lang.ThreadGroup.activeCount
See Also:   java.lang.ThreadGroup.checkAccess
since:
   JDK1.0




enumerate
public int enumerate(ThreadGroup list)(Code)
Copies into the specified array references to every active subgroup in this thread group.

First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

An application might use the activeGroupCount method to get an estimate of how big the array should be, however if the array is too short to hold all the thread groups, the extra thread groups are silently ignored. If it is critical to obtain every active subgroup in this thread group, the caller should verify that the returned int value is strictly less than the length of list.

Due to the inherent race condition in this method, it is recommended that the method only be used for informational purposes.
Parameters:
  list - an array into which to place the list of thread groups. the number of thread groups put into the array.
exception:
  SecurityException - if the current thread does nothave permission to enumerate this thread group.
See Also:   java.lang.ThreadGroup.activeGroupCount
See Also:   java.lang.ThreadGroup.checkAccess
since:
   JDK1.0




enumerate
public int enumerate(ThreadGroup list, boolean recurse)(Code)
Copies into the specified array references to every active subgroup in this thread group. If the recurse flag is true, references to all active subgroups of the subgroups and so forth are also included.

First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

An application might use the activeGroupCount method to get an estimate of how big the array should be, however if the array is too short to hold all the thread groups, the extra thread groups are silently ignored. If it is critical to obtain every active subgroup in this thread group, the caller should verify that the returned int value is strictly less than the length of list.

Due to the inherent race condition in this method, it is recommended that the method only be used for informational purposes.
Parameters:
  list - an array into which to place the list of threads.
Parameters:
  recurse - a flag indicating whether to recursively enumerateall included thread groups. the number of thread groups put into the array.
exception:
  SecurityException - if the current thread does nothave permission to enumerate this thread group.
See Also:   java.lang.ThreadGroup.activeGroupCount
See Also:   java.lang.ThreadGroup.checkAccess
since:
   JDK1.0




getMaxPriority
final public int getMaxPriority()(Code)
Returns the maximum priority of this thread group. Threads that are part of this group cannot have a higher priority than the maximum priority. the maximum priority that a thread in this thread groupcan have.
See Also:   ThreadGroup.setMaxPriority
since:
   JDK1.0



getName
final public String getName()(Code)
Returns the name of this thread group. the name of this thread group.
since:
   JDK1.0



getParent
final public ThreadGroup getParent()(Code)
Returns the parent of this thread group.

First, if the parent is not null, the checkAccess method of the parent thread group is called with no arguments; this may result in a security exception. the parent of this thread group. The top-level thread groupis the only thread group whose parent is null.
exception:
  SecurityException - if the current thread cannot modifythis thread group.
See Also:   java.lang.ThreadGroup.checkAccess
See Also:   java.lang.SecurityException
See Also:   java.lang.RuntimePermission
since:
   JDK1.0




interrupt
final public void interrupt()(Code)
Interrupts all threads in this thread group.

First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

This method then calls the interrupt method on all the threads in this thread group and in all of its subgroups.
exception:
  SecurityException - if the current thread is not allowedto access this thread group or any of the threads inthe thread group.
See Also:   java.lang.Thread.interrupt
See Also:   java.lang.SecurityException
See Also:   java.lang.ThreadGroup.checkAccess
since:
   1.2




isDaemon
final public boolean isDaemon()(Code)
Tests if this thread group is a daemon thread group. A daemon thread group is automatically destroyed when its last thread is stopped or its last thread group is destroyed. true if this thread group is a daemon thread group;false otherwise.
since:
   JDK1.0



isDestroyed
public synchronized boolean isDestroyed()(Code)
Tests if this thread group has been destroyed. true if this object is destroyed
since:
   JDK1.1



list
public void list()(Code)
Prints information about this thread group to the standard output. This method is useful only for debugging.
since:
   JDK1.0



list
void list(PrintStream out, int indent)(Code)



parentOf
final public boolean parentOf(ThreadGroup g)(Code)
Tests if this thread group is either the thread group argument or one of its ancestor thread groups.
Parameters:
  g - a thread group. true if this thread group is the thread groupargument or one of its ancestor thread groups;false otherwise.
since:
   JDK1.0



remove
void remove(Thread t)(Code)
Removes the specified Thread from this group.
Parameters:
  t - the Thread to be removed if the Thread has already been destroyed.



resume
final public void resume()(Code)
Resumes all threads in this thread group.

First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

This method then calls the resume method on all the threads in this thread group and in all of its sub groups.
exception:
  SecurityException - if the current thread is not allowed toaccess this thread group or any of the threads in thethread group.
See Also:   java.lang.SecurityException
See Also:   java.lang.Thread.resume
See Also:   java.lang.ThreadGroup.checkAccess
since:
   JDK1.0Thread.suspend




setDaemon
final public void setDaemon(boolean daemon)(Code)
Changes the daemon status of this thread group.

First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

A daemon thread group is automatically destroyed when its last thread is stopped or its last thread group is destroyed.
Parameters:
  daemon - if true, marks this thread group asa daemon thread group; otherwise, marks thisthread group as normal.
exception:
  SecurityException - if the current thread cannot modifythis thread group.
See Also:   java.lang.SecurityException
See Also:   java.lang.ThreadGroup.checkAccess
since:
   JDK1.0




setMaxPriority
final public void setMaxPriority(int pri)(Code)
Sets the maximum priority of the group. Threads in the thread group that already have a higher priority are not affected.

First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

If the pri argument is less than Thread.MIN_PRIORITY or greater than Thread.MAX_PRIORITY , the maximum priority of the group remains unchanged.

Otherwise, the priority of this ThreadGroup object is set to the smaller of the specified pri and the maximum permitted priority of the parent of this thread group. (If this thread group is the system thread group, which has no parent, then its maximum priority is simply set to pri.) Then this method is called recursively, with pri as its argument, for every thread group that belongs to this thread group.
Parameters:
  pri - the new priority of the thread group.
exception:
  SecurityException - if the current thread cannot modifythis thread group.
See Also:   ThreadGroup.getMaxPriority
See Also:   java.lang.SecurityException
See Also:   java.lang.ThreadGroup.checkAccess
since:
   JDK1.0




stop
final public void stop()(Code)
Stops all threads in this thread group.

First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

This method then calls the stop method on all the threads in this thread group and in all of its subgroups.
exception:
  SecurityException - if the current thread is not allowedto access this thread group or any of the threads inthe thread group.
See Also:   java.lang.SecurityException
See Also:   java.lang.Thread.stop
See Also:   java.lang.ThreadGroup.checkAccess
since:
   JDK1.0Thread.stop




suspend
final public void suspend()(Code)
Suspends all threads in this thread group.

First, the checkAccess method of this thread group is called with no arguments; this may result in a security exception.

This method then calls the suspend method on all the threads in this thread group and in all of its subgroups.
exception:
  SecurityException - if the current thread is not allowedto access this thread group or any of the threads inthe thread group.
See Also:   java.lang.Thread.suspend
See Also:   java.lang.SecurityException
See Also:   java.lang.ThreadGroup.checkAccess
since:
   JDK1.0Thread.suspend




toString
public String toString()(Code)
Returns a string representation of this Thread group. a string representation of this thread group.
since:
   JDK1.0



uncaughtException
public void uncaughtException(Thread t, Throwable e)(Code)
Called by the 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.

The uncaughtException method of ThreadGroup does the following:

  • If this thread group has a parent thread group, the uncaughtException method of that parent is called with the same two arguments.
  • Otherwise, this method checks to see if there is a installed, and if so, its uncaughtException method is called with the same two arguments.
  • Otherwise, this method determines if the Throwable argument is an instance of ThreadDeath . If so, nothing special is done. Otherwise, a message containing the thread's name, as returned from the thread's Thread.getName getName method, and a stack backtrace, using the Throwable's Throwable.printStackTrace printStackTrace method, is printed to the .

Applications can override this method in subclasses of ThreadGroup to provide alternative handling of uncaught exceptions.
Parameters:
  t - the thread that is about to exit.
Parameters:
  e - the uncaught exception.
since:
   JDK1.0




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.