<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<!--NewPage-->
<html>
<head>
<!-- Generated by javadoc on Wed Jul 28 01:21:15 GMT 1999 -->
<title>
  Class java.lang.Thread
</title>
</head>
<body>
<a name="_top_"></a>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.lang.html">This Package</a>  <a href="java.lang.System.html#_top_">Previous</a>  <a href="java.lang.ThreadGroup.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
<hr>
<h1>
  Class java.lang.Thread
</h1>
<pre>
<a href="java.lang.Object.html#_top_">java.lang.Object</a>
   |
   +----java.lang.Thread
</pre>
<hr>
<dl>
  <dt> public class <b>Thread</b>
  <dt> extends <a href="java.lang.Object.html#_top_">Object</a>
  <dt> implements <a href="java.lang.Runnable.html#_top_">Runnable</a>
</dl>
A <i>thread</i> is a thread of execution in a program. The Java
 Virtual Machine allows an application to have multiple threads of
 execution running concurrently.
 <p>
 Every thread has a priority. Threads with higher priority are
 executed in preference to threads with lower priority. Each thread
 may or may not also be marked as a daemon. When code running in
 some thread creates a new <code>Thread</code> object, the new
 thread has its priority initially set equal to the priority of the
 creating thread, and is a daemon thread if and only if the
 creating thread is a daemon.
 <p>
 When a Java Virtual Machine starts up, there is usually a single
 non-daemon thread (which typically calls the method named
 <code>main</code> of some designated class). The Java Virtual
 Machine continues to execute threads until either of the following
 occurs:
 <ul>
 <li>The <code>exit</code> method of class <code>Runtime</code> has been
     called and the security manager has permitted the exit operation
     to take place.
 <li>All threads that are not daemon threads have died, either by
     returning from the call to the <code>run</code> method or by
     performing the <code>stop</code> method.
 </ul>
 <p>
 There are two ways to create a new thread of execution. One is to
 declare a class to be a subclass of <code>Thread</code>. This
 subclass should override the <code>run</code> method of class
 <code>Thread</code>. An instance of the subclass can then be
 allocated and started. For example, a thread that computes primes
 larger than a stated value could be written as follows:
 <p><hr><blockquote><pre>
     class PrimeThread extends Thread {
         long minPrime;
         PrimeThread(long minPrime) {
             this.minPrime = minPrime;
         }
         public void run() {
             // compute primes larger than minPrime
             &nbsp;.&nbsp;.&nbsp;.
         }
     }
 </pre></blockquote><hr>
 <p>
 The following code would then create a thread and start it running:
 <p><blockquote><pre>
     PrimeThread p = new PrimeThread(143);
     p.start();
 </pre></blockquote>
 <p>
 The other way to create a thread is to declare a class that
 implements the <code>Runnable</code> interface. That class then
 implements the <code>run</code> method. An instance of the class can
 then be allocated, passed as an argument when creating
 <code>Thread</code>, and started. The same example in this other
 style looks like the following:
 <p><hr><blockquote><pre>
     class PrimeRun implements Runnable {
         long minPrime;
         PrimeRun(long minPrime) {
             this.minPrime = minPrime;
         }
         public void run() {
             // compute primes larger than minPrime
             &nbsp;.&nbsp;.&nbsp;.
         }
     }
 </pre></blockquote><hr>
 <p>
 The following code would then create a thread and start it running:
 <p><blockquote><pre>
     PrimeRun p = new PrimeRun(143);
     new Thread(p).start();
 </pre></blockquote>
 <p>
 Every thread has a name for identification purposes. More than
 one thread may have the same name. If a name is not specified when
 a thread is created, a new name is generated for it.
<p>
<dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.lang.Runnable.html#_top_">Runnable</a>, <a href="java.lang.Runtime.html#exit(int)">exit</a>, <a href="#run()">run</a>, <a href="#stop()">stop</a>
</dl>
<hr>
<a name="index"></a>
<h2>
  <img src="images/variable-index.gif" width=207 height=38 alt="Variable Index">
</h2>
<dl>
  <dt> <img src="images/blue-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#MAX_PRIORITY"><b>MAX_PRIORITY</b></a>
  <dd>  The maximum priority that a thread can have.
  <dt> <img src="images/blue-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#MIN_PRIORITY"><b>MIN_PRIORITY</b></a>
  <dd>  The minimum priority that a thread can have.
  <dt> <img src="images/blue-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#NORM_PRIORITY"><b>NORM_PRIORITY</b></a>
  <dd>  The default priority that is assigned to a thread.
</dl>
<h2>
  <img src="images/constructor-index.gif" width=275 height=38 alt="Constructor Index">
</h2>
<dl>
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#Thread()"><b>Thread</b></a>()
  <dd>  Allocates a new <code>Thread</code> object.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#Thread(java.lang.Runnable)"><b>Thread</b></a>(Runnable)
  <dd>  Allocates a new <code>Thread</code> object.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#Thread(java.lang.Runnable, java.lang.String)"><b>Thread</b></a>(Runnable, String)
  <dd>  Allocates a new <code>Thread</code> object.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#Thread(java.lang.String)"><b>Thread</b></a>(String)
  <dd>  Allocates a new <code>Thread</code> object.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#Thread(java.lang.ThreadGroup, java.lang.Runnable)"><b>Thread</b></a>(ThreadGroup, Runnable)
  <dd>  Allocates a new <code>Thread</code> object.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#Thread(java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)"><b>Thread</b></a>(ThreadGroup, Runnable, String)
  <dd>  Allocates a new <code>Thread</code> object so that it has
 <code>target</code> as its run object, has the specified
 <code>name</code> as its name, and belongs to the thread group
 referred to by <code>group</code>.
  <dt> <img src="images/yellow-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#Thread(java.lang.ThreadGroup, java.lang.String)"><b>Thread</b></a>(ThreadGroup, String)
  <dd>  Allocates a new <code>Thread</code> object.
</dl>
<h2>
  <img src="images/method-index.gif" width=207 height=38 alt="Method Index">
</h2>
<dl>
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#activeCount()"><b>activeCount</b></a>()
  <dd>  Returns the current number of active threads in this thread group.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#checkAccess()"><b>checkAccess</b></a>()
  <dd>  Determines if the currently running thread has permission to
 modify this thread.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#countStackFrames()"><b>countStackFrames</b></a>()
  <dd>  Counts the number of stack frames in this thread.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#currentThread()"><b>currentThread</b></a>()
  <dd>  Returns a reference to the currently executing thread object.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#destroy()"><b>destroy</b></a>()
  <dd>  Destroys this thread, without any cleanup.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#dumpStack()"><b>dumpStack</b></a>()
  <dd>  Prints a stack trace of the current thread.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#enumerate(java.lang.Thread[])"><b>enumerate</b></a>(Thread[])
  <dd>  Copies into the specified array every active thread in this
 thread group and its subgroups.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getName()"><b>getName</b></a>()
  <dd>  Returns this thread's name.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getPriority()"><b>getPriority</b></a>()
  <dd>  Returns this thread's priority.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#getThreadGroup()"><b>getThreadGroup</b></a>()
  <dd>  Returns this thread's thread group.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#interrupt()"><b>interrupt</b></a>()
  <dd>  Interrupts this thread.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#interrupted()"><b>interrupted</b></a>()
  <dd>  Tests if the current thread has been interrupted.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#isAlive()"><b>isAlive</b></a>()
  <dd>  Tests if this thread is alive.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#isDaemon()"><b>isDaemon</b></a>()
  <dd>  Tests if this thread is a daemon thread.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#isInterrupted()"><b>isInterrupted</b></a>()
  <dd>  Tests if the current thread has been interrupted.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#join()"><b>join</b></a>()
  <dd>  Waits for this thread to die.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#join(long)"><b>join</b></a>(long)
  <dd>  Waits at most <code>millis</code> milliseconds for this thread to
 die.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#join(long, int)"><b>join</b></a>(long, int)
  <dd>  Waits at most <code>millis</code> milliseconds plus
 <code>nanos</code> nanoseconds for this thread to die.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#resume()"><b>resume</b></a>()
  <dd>  Resumes a suspended thread.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#run()"><b>run</b></a>()
  <dd>  If this thread was constructed using a separate
 <code>Runnable</code> run object, then that
 <code>Runnable</code> object's <code>run</code> method is called;
 otherwise, this method does nothing and returns.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setDaemon(boolean)"><b>setDaemon</b></a>(boolean)
  <dd>  Marks this thread as either a daemon thread or a user thread.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setName(java.lang.String)"><b>setName</b></a>(String)
  <dd>  Changes the name of this thread to be equal to the argument
 <code>name</code>.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#setPriority(int)"><b>setPriority</b></a>(int)
  <dd>  Changes the priority of this thread.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#sleep(long)"><b>sleep</b></a>(long)
  <dd>  Causes the currently executing thread to sleep (temporarily cease
 execution) for the specified number of milliseconds.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#sleep(long, int)"><b>sleep</b></a>(long, int)
  <dd>  Causes the currently executing thread to sleep (cease execution)
 for the specified number of milliseconds plus the specified number
 of nanoseconds.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#start()"><b>start</b></a>()
  <dd>  Causes this thread to begin execution; the Java Virtual Machine
 calls the <code>run</code> method of this thread.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#stop()"><b>stop</b></a>()
  <dd>  Forces the thread to stop executing.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#stop(java.lang.Throwable)"><b>stop</b></a>(Throwable)
  <dd>  Forces the thread to stop executing.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#suspend()"><b>suspend</b></a>()
  <dd>  Suspends this thread.
  <dt> <img src="images/red-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#toString()"><b>toString</b></a>()
  <dd>  Returns a string representation of this thread, including the
 thread's name, priority, and thread group.
  <dt> <img src="images/green-ball-small.gif" width=6 height=6 alt=" o ">
	<a href="#yield()"><b>yield</b></a>()
  <dd>  Causes the currently executing thread object to temporarily pause
 and allow other threads to execute.
</dl>
<a name="variables"></a>
<h2>
  <img src="images/variables.gif" width=153 height=38 alt="Variables">
</h2>
<a name="MIN_PRIORITY"><img src="images/blue-ball.gif" width=12 height=12 alt=" o "></a>
<b>MIN_PRIORITY</b>
<pre>
 public static final int MIN_PRIORITY
</pre>
<dl>
  <dd> The minimum priority that a thread can have.<p>
</dl>
<a name="NORM_PRIORITY"><img src="images/blue-ball.gif" width=12 height=12 alt=" o "></a>
<b>NORM_PRIORITY</b>
<pre>
 public static final int NORM_PRIORITY
</pre>
<dl>
  <dd> The default priority that is assigned to a thread.<p>
</dl>
<a name="MAX_PRIORITY"><img src="images/blue-ball.gif" width=12 height=12 alt=" o "></a>
<b>MAX_PRIORITY</b>
<pre>
 public static final int MAX_PRIORITY
</pre>
<dl>
  <dd> The maximum priority that a thread can have.<p>
</dl>
<a name="constructors"></a>
<h2>
  <img src="images/constructors.gif" width=231 height=38 alt="Constructors">
</h2>
<a name="Thread"></a>
<a name="Thread()"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>Thread</b>
<pre>
 public Thread()
</pre>
<dl>
  <dd> Allocates a new <code>Thread</code> object. This constructor has
 the same effect as <code>Thread(null, null,</code>
 <i>gname</i><code>)</code>, where <b><i>gname</i></b> is
 a newly generated name. Automatically generated names are of the
 form <code>"Thread-"+</code><i>n</i>, where <i>n</i> is an integer.
 <p>
 Threads created this way must have overridden their
 <code>run()</code> method to actually do anything.  An example
 illustrating this method being used follows:
 <p><blockquote><pre>
     import java.lang.*;
     class plain01 implements Runnable {
         String name;
         plain01() {
             name = null;
         }
         plain01(String s) {
             name = s;
         }
         public void run() {
             if (name == null)
                 System.out.println("A new thread created");
             else
                 System.out.println("A new thread with name " + name +
                                    " created");
         }
     }
     class threadtest01 {
         public static void main(String args[] ) {
             int failed = 0 ;
             <b>Thread t1 = new Thread();</b>
             if (t1 != null)
                 System.out.println("new Thread() succeed");
             else {
                 System.out.println("new Thread() failed");
                 failed++;
             }
         }
     }
 </pre></blockquote>
<p>
  <dd><dl>
    <dt> <b>See Also:</b>
    <dd> <a href="#Thread(java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)">Thread</a>
  </dl></dd>
</dl>
<a name="Thread(java.lang.Runnable)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>Thread</b>
<pre>
 public Thread(<a href="java.lang.Runnable.html#_top_">Runnable</a> target)
</pre>
<dl>
  <dd> Allocates a new <code>Thread</code> object. This constructor has
 the same effect as <code>Thread(null, target,</code>
 <i>gname</i><code>)</code>, where <i>gname</i> is
 a newly generated name. Automatically generated names are of the
 form <code>"Thread-"+</code><i>n</i>, where <i>n</i> is an integer.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> target - the object whose <code>run</code> method is called.
    <dt> <b>See Also:</b>
    <dd> <a href="#Thread(java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)">Thread</a>
  </dl></dd>
</dl>
<a name="Thread(java.lang.ThreadGroup, java.lang.Runnable)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>Thread</b>
<pre>
 public Thread(<a href="java.lang.ThreadGroup.html#_top_">ThreadGroup</a> group,
               <a href="java.lang.Runnable.html#_top_">Runnable</a> target)
</pre>
<dl>
  <dd> Allocates a new <code>Thread</code> object. This constructor has
 the same effect as <code>Thread(group, target,</code>
 <i>gname</i><code>)</code>, where <i>gname</i> is
 a newly generated name. Automatically generated names are of the
 form <code>"Thread-"+</code><i>n</i>, where <i>n</i> is an integer.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> group - the thread group.
    <dd> target - the object whose <code>run</code> method is called.
    <dt> <b>Throws:</b> <a href="java.lang.SecurityException.html#_top_">SecurityException</a>
    <dd> if the current thread cannot create a
               thread in the specified thread group.
    <dt> <b>See Also:</b>
    <dd> <a href="#Thread(java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)">Thread</a>
  </dl></dd>
</dl>
<a name="Thread(java.lang.String)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>Thread</b>
<pre>
 public Thread(<a href="java.lang.String.html#_top_">String</a> name)
</pre>
<dl>
  <dd> Allocates a new <code>Thread</code> object. This constructor has
 the same effect as <code>Thread(null, null, name)</code>.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> name - the name of the new thread.
    <dt> <b>See Also:</b>
    <dd> <a href="#Thread(java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)">Thread</a>
  </dl></dd>
</dl>
<a name="Thread(java.lang.ThreadGroup, java.lang.String)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>Thread</b>
<pre>
 public Thread(<a href="java.lang.ThreadGroup.html#_top_">ThreadGroup</a> group,
               <a href="java.lang.String.html#_top_">String</a> name)
</pre>
<dl>
  <dd> Allocates a new <code>Thread</code> object. This constructor has
 the same effect as <code>Thread(group, null, name)</code>
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> group - the thread group.
    <dd> name - the name of the new thread.
    <dt> <b>Throws:</b> <a href="java.lang.SecurityException.html#_top_">SecurityException</a>
    <dd> if the current thread cannot create a
               thread in the specified thread group.
    <dt> <b>See Also:</b>
    <dd> <a href="#Thread(java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)">Thread</a>
  </dl></dd>
</dl>
<a name="Thread(java.lang.Runnable, java.lang.String)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>Thread</b>
<pre>
 public Thread(<a href="java.lang.Runnable.html#_top_">Runnable</a> target,
               <a href="java.lang.String.html#_top_">String</a> name)
</pre>
<dl>
  <dd> Allocates a new <code>Thread</code> object. This constructor has
 the same effect as <code>Thread(null, target, name)</code>.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> target - the object whose <code>run</code> method is called.
    <dd> name - the name of the new thread.
    <dt> <b>See Also:</b>
    <dd> <a href="#Thread(java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)">Thread</a>
  </dl></dd>
</dl>
<a name="Thread(java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)"><img src="images/yellow-ball.gif" width=12 height=12 alt=" o "></a>
<b>Thread</b>
<pre>
 public Thread(<a href="java.lang.ThreadGroup.html#_top_">ThreadGroup</a> group,
               <a href="java.lang.Runnable.html#_top_">Runnable</a> target,
               <a href="java.lang.String.html#_top_">String</a> name)
</pre>
<dl>
  <dd> Allocates a new <code>Thread</code> object so that it has
 <code>target</code> as its run object, has the specified
 <code>name</code> as its name, and belongs to the thread group
 referred to by <code>group</code>.
 <p>
 If <code>group</code> is not <code>null</code>, the
 <code>checkAccess</code> method of that thread group is called with
 no arguments; this may result in throwing a
 <code>SecurityException</code>; if <code>group</code> is
 <code>null</code>, the new process belongs to the same group as
 the thread that is creating the new thread.
 <p>
 If the <code>target</code> argument is not <code>null</code>, the
 <code>run</code> method of the <code>target</code> is called when
 this thread is started. If the target argument is
 <code>null</code>, this thread's <code>run</code> method is called
 when this thread is started.
 <p>
 The priority of the newly created thread is set equal to the
 priority of the thread creating it, that is, the currently running
 thread. The method <code>setPriority</code> may be used to
 change the priority to a new value.
 <p>
 The newly created thread is initially marked as being a daemon
 thread if and only if the thread creating it is currently marked
 as a daemon thread. The method <code>setDaemon </code> may be used
 to change whether or not a thread is a daemon.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> group - the thread group.
    <dd> target - the object whose <code>run</code> method is called.
    <dd> name - the name of the new thread.
    <dt> <b>Throws:</b> <a href="java.lang.SecurityException.html#_top_">SecurityException</a>
    <dd> if the current thread cannot create a
               thread in the specified thread group.
    <dt> <b>See Also:</b>
    <dd> <a href="java.lang.Runnable.html#run()">run</a>, <a href="#run()">run</a>, <a href="#setDaemon(boolean)">setDaemon</a>, <a href="#setPriority(int)">setPriority</a>, <a href="java.lang.ThreadGroup.html#checkAccess()">checkAccess</a>
  </dl></dd>
</dl>
<a name="methods"></a>
<h2>
  <img src="images/methods.gif" width=151 height=38 alt="Methods">
</h2>
<a name="currentThread()"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="currentThread"><b>currentThread</b></a>
<pre>
 public static native <a href="#_top_">Thread</a> currentThread()
</pre>
<dl>
  <dd> Returns a reference to the currently executing thread object.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the currently executing thread.
  </dl></dd>
</dl>
<a name="yield()"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="yield"><b>yield</b></a>
<pre>
 public static native void yield()
</pre>
<dl>
  <dd> Causes the currently executing thread object to temporarily pause
 and allow other threads to execute.
<p>
</dl>
<a name="sleep(long)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="sleep"><b>sleep</b></a>
<pre>
 public static native void sleep(long millis) throws <a href="java.lang.InterruptedException.html#_top_">InterruptedException</a>
</pre>
<dl>
  <dd> Causes the currently executing thread to sleep (temporarily cease
 execution) for the specified number of milliseconds. The thread
 does not lose ownership of any monitors.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> millis - the length of time to sleep in milliseconds.
    <dt> <b>Throws:</b> <a href="java.lang.InterruptedException.html#_top_">InterruptedException</a>
    <dd> if another thread has interrupted
               this thread.
    <dt> <b>See Also:</b>
    <dd> <a href="java.lang.Object.html#notify()">notify</a>
  </dl></dd>
</dl>
<a name="sleep(long, int)"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="sleep"><b>sleep</b></a>
<pre>
 public static void sleep(long millis,
                          int nanos) throws <a href="java.lang.InterruptedException.html#_top_">InterruptedException</a>
</pre>
<dl>
  <dd> Causes the currently executing thread to sleep (cease execution)
 for the specified number of milliseconds plus the specified number
 of nanoseconds. The thread does not lose ownership of any monitors.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> millis - the length of time to sleep in milliseconds.
    <dd> nanos - 0-999999 additional nanoseconds to sleep.
    <dt> <b>Throws:</b> <a href="java.lang.IllegalArgumentException.html#_top_">IllegalArgumentException</a>
    <dd> if the value of millis is negative
               or the value of nanos is not in the range 0-999999.
    <dt> <b>Throws:</b> <a href="java.lang.InterruptedException.html#_top_">InterruptedException</a>
    <dd> if another thread has interrupted
               this thread.
    <dt> <b>See Also:</b>
    <dd> <a href="java.lang.Object.html#notify()">notify</a>
  </dl></dd>
</dl>
<a name="start()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="start"><b>start</b></a>
<pre>
 public native synchronized void start()
</pre>
<dl>
  <dd> Causes this thread to begin execution; the Java Virtual Machine
 calls the <code>run</code> method of this thread.
 <p>
 The result is that two threads are running concurrently: the
 current thread (which returns from the call to the
 <code>start</code> method) and the other thread (which executes its
 <code>run</code> method).
<p>
  <dd><dl>
    <dt> <b>Throws:</b> <a href="java.lang.IllegalThreadStateException.html#_top_">IllegalThreadStateException</a>
    <dd> if the thread was already
               started.
    <dt> <b>See Also:</b>
    <dd> <a href="#run()">run</a>, <a href="#stop()">stop</a>
  </dl></dd>
</dl>
<a name="run()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="run"><b>run</b></a>
<pre>
 public void run()
</pre>
<dl>
  <dd> If this thread was constructed using a separate
 <code>Runnable</code> run object, then that
 <code>Runnable</code> object's <code>run</code> method is called;
 otherwise, this method does nothing and returns.
 <p>
 Subclasses of <code>Thread</code> should override this method.
<p>
  <dd><dl>
    <dt> <b>See Also:</b>
    <dd> <a href="#start()">start</a>, <a href="#stop()">stop</a>, <a href="#Thread(java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)">Thread</a>, <a href="java.lang.Runnable.html#run()">run</a>
  </dl></dd>
</dl>
<a name="stop()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="stop"><b>stop</b></a>
<pre>
 public final void stop()
</pre>
<dl>
  <dd> Forces the thread to stop executing.
 <p>
 First, the <code>checkAccess</code> method of this thread is called
 with no arguments. This may result in throwing a
 <code>SecurityException</code> (in the current thread).
 <p>
 The thread represented by this thread is forced to stop whatever
 it is doing abnormally and to throw a newly created
 <code>ThreadDeath</code> object as an exception.
 <p>
 It is permitted to stop a thread that has not yet been started.
 If the thread is eventually started, it immediately terminates.
 <p>
 An application should not normally try to catch
 <code>ThreadDeath</code> unless it must do some extraordinary
 cleanup operation (note that the throwing of
 <code>ThreadDeath</code> causes <code>finally</code> clauses of
 <code>try</code> statements to be executed before the thread
 officially dies).  If a <code>catch</code> clause catches a
 <code>ThreadDeath</code> object, it is important to rethrow the
 object so that the thread actually dies.
 <p>
 The top-level error handler that reacts to otherwise uncaught
 exceptions does not print out a message or otherwise notify the
 application if the uncaught exception is an instance of
 <code>ThreadDeath</code>.
 <p>
 Note: the use of this method is unsafe as it can result in the
 corruption of invariants. Stopping a thread with Thread.stop causes
 it to unlock all of the monitors that it has locked (as a natural
 consequence of the unchecked <code>ThreadDeath</code> exception
 propagating up the stack). If any of the objects previously protected
 by these monitors were in an inconsistent state, the damaged objects
 become visible to other threads potentially resulting in arbitrary
 behaviour. Many uses of <code>stop</code> should be replaced by code
 that simply modifies some volatile variable to indicate that the target
 thread should stop running. The target thread should check this
 variable regularly, and return from its run method in an orderly
 fashion if the variable indicates that it is to stop running. If the
 target thread waits for long periods, the interrupt method should be
 used to interrupt the wait.
<p>
  <dd><dl>
    <dt> <b>Throws:</b> <a href="java.lang.SecurityException.html#_top_">SecurityException</a>
    <dd> if the current thread cannot modify
               this thread.
    <dt> <b>See Also:</b>
    <dd> <a href="#checkAccess()">checkAccess</a>, <a href="#run()">run</a>, <a href="#start()">start</a>, <a href="java.lang.ThreadDeath.html#_top_">ThreadDeath</a>, <a href="java.lang.ThreadGroup.html#uncaughtException(java.lang.Thread, java.lang.Throwable)">uncaughtException</a>
  </dl></dd>
</dl>
<a name="stop(java.lang.Throwable)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="stop"><b>stop</b></a>
<pre>
 public final synchronized void stop(<a href="java.lang.Throwable.html#_top_">Throwable</a> o)
</pre>
<dl>
  <dd> Forces the thread to stop executing.
 <p>
 First, the <code>checkAccess</code> method of this thread is called
 with no arguments. This may result in throwing a
 <code>SecurityException </code>(in the current thread).
 <p>
 If the argument <code>obj</code> is null, a
 <code>NullPointerException</code> is thrown (in the current thread).
 <p>
 The thread represented by this thread is forced to complete
 whatever it is doing abnormally and to throw the
 <code>Throwable</code> object <code>obj</code> as an exception. This
 is an unusual action to take; normally, the <code>stop</code> method
 that takes no arguments should be used.
 <p>
 It is permitted to stop a thread that has not yet been started.
 If the thread is eventually started, it immediately terminates.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> obj - the Throwable object to be thrown.
    <dt> <b>Throws:</b> <a href="java.lang.SecurityException.html#_top_">SecurityException</a>
    <dd> if the current thread cannot modify
               this thread.
    <dt> <b>See Also:</b>
    <dd> <a href="#checkAccess()">checkAccess</a>, <a href="#run()">run</a>, <a href="#start()">start</a>, <a href="#stop()">stop</a>
  </dl></dd>
</dl>
<a name="interrupt()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="interrupt"><b>interrupt</b></a>
<pre>
 public void interrupt()
</pre>
<dl>
  <dd> Interrupts this thread.
<p>
</dl>
<a name="interrupted()"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="interrupted"><b>interrupted</b></a>
<pre>
 public static boolean interrupted()
</pre>
<dl>
  <dd> Tests if the current thread has been interrupted.
 Note that <code>interrupted</code> is a static method, while
 <code>isInterrupted</code> is called on the current
 <code>Thread</code> instance.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> <code>true</code> if the current thread has been interrupted;
          <code>false</code> otherwise.
    <dt> <b>See Also:</b>
    <dd> <a href="#isInterrupted()">isInterrupted</a>
  </dl></dd>
</dl>
<a name="isInterrupted()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="isInterrupted"><b>isInterrupted</b></a>
<pre>
 public boolean isInterrupted()
</pre>
<dl>
  <dd> Tests if the current thread has been interrupted.
 Note that <code>isInterrupted</code>
 is called on the current <code>Thread</code> instance; by
 contrast, <code>interrupted</code> is a static method.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> <code>true</code> if this thread has been interrupted;
          <code>false</code> otherwise.
    <dt> <b>See Also:</b>
    <dd> <a href="#interrupted()">interrupted</a>
  </dl></dd>
</dl>
<a name="destroy()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="destroy"><b>destroy</b></a>
<pre>
 public void destroy()
</pre>
<dl>
  <dd> Destroys this thread, without any cleanup. Any monitors it has
 locked remain locked. (This method is not implemented in
 Java&nbsp;1.0.2.)
<p>
</dl>
<a name="isAlive()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="isAlive"><b>isAlive</b></a>
<pre>
 public final native boolean isAlive()
</pre>
<dl>
  <dd> Tests if this thread is alive. A thread is alive if it has
 been started and has not yet died.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> <code>true</code> if this thread is alive;
          <code>false</code> otherwise.
  </dl></dd>
</dl>
<a name="suspend()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="suspend"><b>suspend</b></a>
<pre>
 public final void suspend()
</pre>
<dl>
  <dd> Suspends this thread.
 <p>
 First, the <code>checkAccess</code> method of this thread is called
 with no arguments. This may result in throwing a
 <code>SecurityException </code>(in the current thread).
 <p>
 If the thread is alive, it is suspended and makes no further
 progress unless and until it is resumed.
<p>
  <dd><dl>
    <dt> <b>Throws:</b> <a href="java.lang.SecurityException.html#_top_">SecurityException</a>
    <dd> if the current thread cannot modify
               this thread.
    <dt> <b>See Also:</b>
    <dd> <a href="#checkAccess()">checkAccess</a>, <a href="#isAlive()">isAlive</a>
  </dl></dd>
</dl>
<a name="resume()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="resume"><b>resume</b></a>
<pre>
 public final void resume()
</pre>
<dl>
  <dd> Resumes a suspended thread.
 <p>
 First, the <code>checkAccess</code> method of this thread is called
 with no arguments. This may result in throwing a
 <code>SecurityException</code>(in the current thread).
 <p>
 If the thread is alive but suspended, it is resumed and is
 permitted to make progress in its execution.
<p>
  <dd><dl>
    <dt> <b>Throws:</b> <a href="java.lang.SecurityException.html#_top_">SecurityException</a>
    <dd> if the current thread cannot modify this
               thread.
    <dt> <b>See Also:</b>
    <dd> <a href="#checkAccess()">checkAccess</a>, <a href="#isAlive()">isAlive</a>
  </dl></dd>
</dl>
<a name="setPriority(int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setPriority"><b>setPriority</b></a>
<pre>
 public final void setPriority(int newPriority)
</pre>
<dl>
  <dd> Changes the priority of this thread.
 <p>
 First the <code>checkAccess</code> method of this thread is called
 with no arguments. This may result in throwing a
 <code>SecurityException</code>.
 <p>
 Otherwise, the priority of this thread is set to the smaller of
 the specified <code>newPriority</code> and the maximum permitted
 priority of the thread's thread group.
<p>
  <dd><dl>
    <dt> <b>Throws:</b> <a href="java.lang.IllegalArgumentException.html#_top_">IllegalArgumentException</a>
    <dd> If the priority is not in the
               range <code>MIN_PRIORITY</code> to
               <code>MAX_PRIORITY</code>.
    <dt> <b>Throws:</b> <a href="java.lang.SecurityException.html#_top_">SecurityException</a>
    <dd> if the current thread cannot modify
               this thread.
    <dt> <b>See Also:</b>
    <dd> <a href="#checkAccess()">checkAccess</a>, <a href="#getPriority()">getPriority</a>, <a href="#getThreadGroup()">getThreadGroup</a>, <a href="#MAX_PRIORITY">MAX_PRIORITY</a>, <a href="#MIN_PRIORITY">MIN_PRIORITY</a>, <a href="java.lang.ThreadGroup.html#getMaxPriority()">getMaxPriority</a>
  </dl></dd>
</dl>
<a name="getPriority()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getPriority"><b>getPriority</b></a>
<pre>
 public final int getPriority()
</pre>
<dl>
  <dd> Returns this thread's priority.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> this thread's name.
    <dt> <b>See Also:</b>
    <dd> <a href="#setPriority(int)">setPriority</a>
  </dl></dd>
</dl>
<a name="setName(java.lang.String)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setName"><b>setName</b></a>
<pre>
 public final void setName(<a href="java.lang.String.html#_top_">String</a> name)
</pre>
<dl>
  <dd> Changes the name of this thread to be equal to the argument
 <code>name</code>.
 <p>
 First the <code>checkAccess</code> method of this thread is called
 with no arguments. This may result in throwing a
 <code>SecurityException</code>.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> name - the new name for this thread.
    <dt> <b>Throws:</b> <a href="java.lang.SecurityException.html#_top_">SecurityException</a>
    <dd> if the current thread cannot modify this
               thread.
    <dt> <b>See Also:</b>
    <dd> <a href="#checkAccess()">checkAccess</a>, <a href="#getName()">getName</a>
  </dl></dd>
</dl>
<a name="getName()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getName"><b>getName</b></a>
<pre>
 public final <a href="java.lang.String.html#_top_">String</a> getName()
</pre>
<dl>
  <dd> Returns this thread's name.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> this thread's name.
    <dt> <b>See Also:</b>
    <dd> <a href="#setName(java.lang.String)">setName</a>
  </dl></dd>
</dl>
<a name="getThreadGroup()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="getThreadGroup"><b>getThreadGroup</b></a>
<pre>
 public final <a href="java.lang.ThreadGroup.html#_top_">ThreadGroup</a> getThreadGroup()
</pre>
<dl>
  <dd> Returns this thread's thread group.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> this thread's thread group.
  </dl></dd>
</dl>
<a name="activeCount()"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="activeCount"><b>activeCount</b></a>
<pre>
 public static int activeCount()
</pre>
<dl>
  <dd> Returns the current number of active threads in this thread group.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the current number of threads in this thread's thread group.
  </dl></dd>
</dl>
<a name="enumerate(java.lang.Thread[])"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="enumerate"><b>enumerate</b></a>
<pre>
 public static int enumerate(<a href="#_top_">Thread</a> tarray[])
</pre>
<dl>
  <dd> Copies into the specified array every active thread in this
 thread group and its subgroups. This method simply calls the
 <code>enumerate</code> method of this thread's thread group with
 the array argument.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the number of threads put into the array.
    <dt> <b>See Also:</b>
    <dd> <a href="java.lang.ThreadGroup.html#enumerate(java.lang.Thread[])">enumerate</a>
  </dl></dd>
</dl>
<a name="countStackFrames()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="countStackFrames"><b>countStackFrames</b></a>
<pre>
 public native int countStackFrames()
</pre>
<dl>
  <dd> Counts the number of stack frames in this thread. The thread must
 be suspended.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> the number of stack frames in this thread.
    <dt> <b>Throws:</b> <a href="java.lang.IllegalThreadStateException.html#_top_">IllegalThreadStateException</a>
    <dd> if this thread is not suspended.
  </dl></dd>
</dl>
<a name="join(long)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="join"><b>join</b></a>
<pre>
 public final synchronized void join(long millis) throws <a href="java.lang.InterruptedException.html#_top_">InterruptedException</a>
</pre>
<dl>
  <dd> Waits at most <code>millis</code> milliseconds for this thread to
 die. A timeout of <code>0</code> means to wait forever.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> millis - the time to wait in milliseconds.
    <dt> <b>Throws:</b> <a href="java.lang.InterruptedException.html#_top_">InterruptedException</a>
    <dd> if another thread has interrupted the
               current thread.
  </dl></dd>
</dl>
<a name="join(long, int)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="join"><b>join</b></a>
<pre>
 public final synchronized void join(long millis,
                                     int nanos) throws <a href="java.lang.InterruptedException.html#_top_">InterruptedException</a>
</pre>
<dl>
  <dd> Waits at most <code>millis</code> milliseconds plus
 <code>nanos</code> nanoseconds for this thread to die.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> millis - the time to wait in milliseconds.
    <dd> nanos - 0-999999 additional nanoseconds to wait.
    <dt> <b>Throws:</b> <a href="java.lang.IllegalArgumentException.html#_top_">IllegalArgumentException</a>
    <dd> if the value of millis is negative
               the value of nanos is not in the range 0-999999.
    <dt> <b>Throws:</b> <a href="java.lang.InterruptedException.html#_top_">InterruptedException</a>
    <dd> if another thread has interrupted the
               current thread.
  </dl></dd>
</dl>
<a name="join()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="join"><b>join</b></a>
<pre>
 public final void join() throws <a href="java.lang.InterruptedException.html#_top_">InterruptedException</a>
</pre>
<dl>
  <dd> Waits for this thread to die.
<p>
  <dd><dl>
    <dt> <b>Throws:</b> <a href="java.lang.InterruptedException.html#_top_">InterruptedException</a>
    <dd> if another thread has interrupted the
               current thread.
  </dl></dd>
</dl>
<a name="dumpStack()"><img src="images/green-ball.gif" width=12 height=12 alt=" o "></a>
<a name="dumpStack"><b>dumpStack</b></a>
<pre>
 public static void dumpStack()
</pre>
<dl>
  <dd> Prints a stack trace of the current thread. This method is used
 only for debugging.
<p>
  <dd><dl>
    <dt> <b>See Also:</b>
    <dd> <a href="java.lang.Throwable.html#printStackTrace()">printStackTrace</a>
  </dl></dd>
</dl>
<a name="setDaemon(boolean)"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="setDaemon"><b>setDaemon</b></a>
<pre>
 public final void setDaemon(boolean on)
</pre>
<dl>
  <dd> Marks this thread as either a daemon thread or a user thread. The
 Java Virtual Machine exits when the only threads running are all
 daemon threads.
 <p>
 This method must be called before the thread is started.
<p>
  <dd><dl>
    <dt> <b>Parameters:</b>
    <dd> on - if <code>true</code>, marks this thread as a
                  daemon thread.
    <dt> <b>Throws:</b> <a href="java.lang.IllegalThreadStateException.html#_top_">IllegalThreadStateException</a>
    <dd> if this thread is active.
    <dt> <b>See Also:</b>
    <dd> <a href="#isDaemon()">isDaemon</a>
  </dl></dd>
</dl>
<a name="isDaemon()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="isDaemon"><b>isDaemon</b></a>
<pre>
 public final boolean isDaemon()
</pre>
<dl>
  <dd> Tests if this thread is a daemon thread.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> <code>true</code> if this thread is a daemon thread;
          <code>false</code> otherwise.
    <dt> <b>See Also:</b>
    <dd> <a href="#setDaemon(boolean)">setDaemon</a>
  </dl></dd>
</dl>
<a name="checkAccess()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="checkAccess"><b>checkAccess</b></a>
<pre>
 public void checkAccess()
</pre>
<dl>
  <dd> Determines if the currently running thread has permission to
 modify this thread.
 <p>
 If there is a security manager, its <code>checkAccess</code> method
 is called with this thread as its argument. This may result in
 throwing a <code>SecurityException</code>.
<p>
  <dd><dl>
    <dt> <b>Throws:</b> <a href="java.lang.SecurityException.html#_top_">SecurityException</a>
    <dd> if the current thread is not allowed to
               access this thread.
    <dt> <b>See Also:</b>
    <dd> <a href="java.lang.SecurityManager.html#checkAccess(java.lang.Thread)">checkAccess</a>
  </dl></dd>
</dl>
<a name="toString()"><img src="images/red-ball.gif" width=12 height=12 alt=" o "></a>
<a name="toString"><b>toString</b></a>
<pre>
 public <a href="java.lang.String.html#_top_">String</a> toString()
</pre>
<dl>
  <dd> Returns a string representation of this thread, including the
 thread's name, priority, and thread group.
<p>
  <dd><dl>
    <dt> <b>Returns:</b>
    <dd> a string representation of this thread.
    <dt> <b>Overrides:</b>
    <dd> <a href="java.lang.Object.html#toString()">toString</a> in class <a href="java.lang.Object.html#_top_">Object</a>
  </dl></dd>
</dl>
<hr>
<pre>
<a href="packages.html">All Packages</a>  <a href="tree.html">Class Hierarchy</a>  <a href="Package-java.lang.html">This Package</a>  <a href="java.lang.System.html#_top_">Previous</a>  <a href="java.lang.ThreadGroup.html#_top_">Next</a>  <a href="AllNames.html">Index</a></pre>
</body>
</html>
