API Overview API Index Package Overview Direct link to this page
JDK 1.6
  java.lang. Thread View Source
Author(s)
unascribed
Since
JDK1.0
Version
1.173, 07/13/06
Serial
Hierarchy
 Object
      Thread
Implements
 Runnable
Subclasses
Description
public class Thread
  A thread is a thread of execution in a program.
Constructors
public Thread ()
  Allocates a new Thread object.
public Thread (Runnable target)
  Allocates a new Thread object.
public Thread (Runnable target, String name)
  Allocates a new Thread object.
public Thread (String name)
  Allocates a new Thread object.
public Thread (ThreadGroup group, Runnable target)
  Allocates a new Thread object.
public Thread (ThreadGroup group, Runnable target, String name)
  Allocates a new Thread object so that it has target as its run object, has the specified name as its name, and belongs to the thread group referred to by group.
public Thread (ThreadGroup group, Runnable target, String name, long stackSize)
  Allocates a new Thread object so that it has target as its run object, has the specified name as its name, belongs to the thread group referred to by group, and has the specified stack size.
public Thread (ThreadGroup group, String name)
  Allocates a new Thread object.
Methods
Hide/Show inherited methods
publicstatic int activeCount ()
  Returns the number of active threads in the current thread's thread group.
pack-private void blockedOn (sun.nio.ch.Interruptible b)
publicfinal void checkAccess ()
  Determines if the currently running thread has permission to modify this thread.
@Deprecated
publicnative int countStackFrames ()
  Counts the number of stack frames in this thread.
publicstaticnative Thread currentThread ()
  Returns a reference to the currently executing thread object.
@Deprecated
public void destroy ()
  Throws NoSuchMethodError.
publicstatic void dumpStack ()
  Prints a stack trace of the current thread to the standard error stream.
publicstatic int enumerate (Thread tarray)
  Copies into the specified array every active thread in the current thread's thread group and its subgroups.
publicstatic Map<Thread, StackTraceElement> getAllStackTraces ()
  Returns a map of stack traces for all live threads.
public ClassLoader getContextClassLoader ()
  Returns the context ClassLoader for this Thread.
publicstatic UncaughtExceptionHandler getDefaultUncaughtExceptionHandler ()
  Returns the default handler invoked when a thread abruptly terminates due to an uncaught exception.
public long getId ()
  Returns the identifier of this Thread.
publicfinal String getName ()
  Returns this thread's name.
publicfinal int getPriority ()
  Returns this thread's priority.
public StackTraceElement getStackTrace ()
  Returns an array of stack trace elements representing the stack dump of this thread.
public State getState ()
  Returns the state of this thread.
publicfinal ThreadGroup getThreadGroup ()
  Returns the thread group to which this thread belongs.
public UncaughtExceptionHandler getUncaughtExceptionHandler ()
  Returns the handler invoked when this thread abruptly terminates due to an uncaught exception.
publicstaticnative boolean holdsLock (Object obj)
  Returns true if and only if the current thread holds the monitor lock on the specified object.
public void interrupt ()
  Interrupts this thread.
publicstatic boolean interrupted ()
  Tests whether the current thread has been interrupted.
publicfinalnative boolean isAlive ()
  Tests if this thread is alive.
publicfinal boolean isDaemon ()
  Tests if this thread is a daemon thread.
public boolean isInterrupted ()
  Tests whether this thread has been interrupted.
publicfinal void join () throws InterruptedException
  Waits for this thread to die.
publicfinalsynchronized void join (long millis) throws InterruptedException
  Waits at most millis milliseconds for this thread to die.
publicfinalsynchronized void join (long millis, int nanos) throws InterruptedException
  Waits at most millis milliseconds plus nanos nanoseconds for this thread to die.
@Deprecated
publicfinal void resume ()
  Resumes a suspended thread.
public void run () [Specified in Runnable]
  If this thread was constructed using a separate Runnable run object, then that Runnable object's run method is called; otherwise, this method does nothing and returns.
public void setContextClassLoader (ClassLoader cl)
  Sets the context ClassLoader for this Thread.
publicfinal void setDaemon (boolean on)
  Marks this thread as either a daemon thread or a user thread.
publicstatic void setDefaultUncaughtExceptionHandler (UncaughtExceptionHandler eh)
  Set the default handler invoked when a thread abruptly terminates due to an uncaught exception, and no other handler has been defined for that thread.
publicfinal void setName (String name)
  Changes the name of this thread to be equal to the argument name.
publicfinal void setPriority (int newPriority)
  Changes the priority of this thread.
public void setUncaughtExceptionHandler (UncaughtExceptionHandler eh)
  Set the handler invoked when this thread abruptly terminates due to an uncaught exception.
publicstaticnative void sleep (long millis) throws InterruptedException
  Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds, subject to the precision and accuracy of system timers and schedulers.
publicstatic void sleep (long millis, int nanos) throws InterruptedException
  Causes the currently executing thread to sleep (cease execution) for the specified number of milliseconds plus the specified number of nanoseconds, subject to the precision and accuracy of system timers and schedulers.
publicsynchronized void start ()
  Causes this thread to begin execution; the Java Virtual Machine calls the run method of this thread.
@Deprecated
publicfinal void stop ()
  Forces the thread to stop executing.
@Deprecated
publicfinalsynchronized void stop (Throwable obj)
  Forces the thread to stop executing.
@Deprecated
publicfinal void suspend ()
  Suspends this thread.
public String toString ()
  Returns a string representation of this thread, including the thread's name, priority, and thread group.
publicstaticnative void yield ()
Causes the currently executing thread object to temporarily pause and allow other threads to execute.
Fields
Hide/Show inherited fields
pack-private ThreadLocalMap inheritableThreadLocals
publicfinalstatic int MAX_PRIORITY = "10"
The maximum priority that a thread can have.
publicfinalstatic int MIN_PRIORITY = "1"
The minimum priority that a thread can have.
publicfinalstatic int NORM_PRIORITY = "5"
The default priority that is assigned to a thread.
pack-privatevolatile Object parkBlocker
  The argument supplied to the current call to java.util.concurrent.locks.LockSupport.park.
pack-private ThreadLocalMap threadLocals
Nested Classes
  Thread.State
A thread state.
  Thread.UncaughtExceptionHandler
Interface for handlers invoked when a Thread abruptly terminates due to an uncaught exception.
Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar