img
As expected, these constants specify the maximum, minimum, and default thread priorities.
The methods defined by Thread are shown in Table 16-17. In early versions of Java, Thread
also included the methods stop( ), suspend( ), and resume( ). However, as explained in
Chapter 11, these were deprecated because they were inherently unstable. Also deprecated
are countStackFrames( ), because it calls suspend( ), and destroy( ), because it can cause deadlock.
Method
Description
static int activeCount( )
Returns the number of threads in the group to
which the thread belongs.
final void checkAccess( )
Causes the security manager to verify that the
current thread can access and/or change the
thread on which checkAccess( ) is called.
static Thread currentThread( )
Returns a Thread object that encapsulates the
thread that calls this method.
static void dumpStack( )
Displays the call stack for the thread.
static int enumerate(Thread threads[ ])
Puts copies of all Thread objects in the current
thread's group into threads. The number of threads
is returned.
static Map<Thread, StackTraceElement[ ]>
Returns a Map that contains the stack traces for
getAllStackTraces( )
all active threads. In the map, each entr y consists
of a key, which is the Thread object, and its value,
which is an array of StackTraceElement.
ClassLoader getContextClassLoader( )
Returns the class loader that is used to load
classes and resources for this thread.
static Thread.UncaughtExceptionHandler
Returns the default uncaught exception handler.
getDefaultUncaughtExceptionHandler( )
long getID( )
Returns the ID of the invoking thread.
final String getName( )
Returns the thread's name.
final int getPriority( )
Returns the thread's priority setting.
StackTraceElement[ ] getStackTrace( )
Returns an array containing the stack trace for the
invoking thread.
Thread.State getState( )
Returns the invoking thread's state.
final ThreadGroup getThreadGroup( )
Returns the ThreadGroup object of which the
invoking thread is a member.
Thread.UncaughtExceptionHandler
Returns the invoking thread's uncaught exception
getUncaughtExceptionHandler( )
handler.
static boolean holdsLock(Object ob)
Returns true if the invoking thread owns the lock
on ob. Returns false other wise.
void interrupt( )
Interrupts the thread.
static boolean interrupted( )
Returns true if the currently executing thread has
been scheduled for interruption. Other wise, it
returns false.
TABLE 16-17
The Methods Defined by Thread
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home