⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thread.html

📁 API資料大全
💻 HTML
📖 第 1 页 / 共 5 页
字号:
</DL><HR><A NAME="sleep(long, int)"><!-- --></A><H3>sleep</H3><PRE>public static void <B>sleep</B>(long&nbsp;millis,                         int&nbsp;nanos)                  throws <A HREF="../../java/lang/InterruptedException.html">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.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>millis</CODE> - the length of time to sleep in milliseconds.<DD><CODE>nanos</CODE> - 0-999999 additional nanoseconds to sleep.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalArgumentException.html">IllegalArgumentException</A></CODE> - if the value of millis is              negative or the value of nanos is not in the range              0-999999.<DD><CODE><A HREF="../../java/lang/InterruptedException.html">InterruptedException</A></CODE> - if another thread has interrupted             the current thread.  The <i>interrupted status</i> of the             current thread is cleared when this exception is thrown.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Object.html#notify()"><CODE>Object.notify()</CODE></A></DL></DD></DL><HR><A NAME="start()"><!-- --></A><H3>start</H3><PRE>public void <B>start</B>()</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).<DD><DL></DL></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/IllegalThreadStateException.html">IllegalThreadStateException</A></CODE> - if the thread was already               started.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Thread.html#run()"><CODE>run()</CODE></A>, <A HREF="../../java/lang/Thread.html#stop()"><CODE>stop()</CODE></A></DL></DD></DL><HR><A NAME="run()"><!-- --></A><H3>run</H3><PRE>public void <B>run</B>()</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.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/lang/Runnable.html#run()">run</A></CODE> in interface <CODE><A HREF="../../java/lang/Runnable.html">Runnable</A></CODE></DL></DD><DD><DL><DT><B>See Also: </B><DD><A HREF="../../java/lang/Thread.html#start()"><CODE>start()</CODE></A>, <A HREF="../../java/lang/Thread.html#stop()"><CODE>stop()</CODE></A>, <A HREF="../../java/lang/Thread.html#Thread(java.lang.ThreadGroup, java.lang.Runnable, java.lang.String)"><CODE>Thread(java.lang.ThreadGroup,           java.lang.Runnable, java.lang.String)</CODE></A>, <A HREF="../../java/lang/Runnable.html#run()"><CODE>Runnable.run()</CODE></A></DL></DD></DL><HR><A NAME="stop()"><!-- --></A><H3>stop</H3><PRE>public final void <B>stop</B>()</PRE><DL><DD><B>Deprecated.</B>&nbsp;<I>This method is inherently unsafe.  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 behavior.  Many       uses of <code>stop</code> should be replaced by code that simply       modifies some 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 (on a condition variable,       for example), the <code>interrupt</code> method should be used to       interrupt the wait.        For more information, see        <a href="../../../guide/misc/threadPrimitiveDeprecation.html">Why        are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.</I><P><DD>Forces the thread to stop executing. <p> If there is a security manager installed, its <code>checkAccess</code> method is called with <code>this</code>  as its argument. This may result in a  <code>SecurityException</code> being raised (in the current thread).  <p> If this thread is different from the current thread (that is, the current thread is trying to stop a thread other than itself), the security manager's <code>checkPermission</code> method (with a <code>RuntimePermission("stopThread")</code> argument) is called in addition. Again, 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>.<DD><DL></DL></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if the current thread cannot                modify this thread.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Thread.html#interrupt()"><CODE>interrupt()</CODE></A>, <A HREF="../../java/lang/Thread.html#checkAccess()"><CODE>checkAccess()</CODE></A>, <A HREF="../../java/lang/Thread.html#run()"><CODE>run()</CODE></A>, <A HREF="../../java/lang/Thread.html#start()"><CODE>start()</CODE></A>, <A HREF="../../java/lang/ThreadDeath.html"><CODE>ThreadDeath</CODE></A>, <A HREF="../../java/lang/ThreadGroup.html#uncaughtException(java.lang.Thread, java.lang.Throwable)"><CODE>ThreadGroup.uncaughtException(java.lang.Thread,             java.lang.Throwable)</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkAccess(java.lang.Thread)"><CODE>SecurityManager.checkAccess(Thread)</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkPermission(java.security.Permission)"><CODE>SecurityManager.checkPermission(java.security.Permission)</CODE></A></DL></DD></DL><HR><A NAME="stop(java.lang.Throwable)"><!-- --></A><H3>stop</H3><PRE>public final void <B>stop</B>(<A HREF="../../java/lang/Throwable.html">Throwable</A>&nbsp;obj)</PRE><DL><DD><B>Deprecated.</B>&nbsp;<I>This method is inherently unsafe.  See <A HREF="../../java/lang/Thread.html#stop()"><CODE>stop()</CODE></A>        (with no arguments) for details.  An additional danger of this        method is that it may be used to generate exceptions that the        target thread is unprepared to handle (including checked        exceptions that the thread could not possibly throw, were it        not for this method).        For more information, see         <a href="../../../guide/misc/threadPrimitiveDeprecation.html">Why         are Thread.stop, Thread.suspend and Thread.resume Deprecated?</a>.</I><P><DD>Forces the thread to stop executing. <p> If there is a security manager installed, the <code>checkAccess</code> method of this thread is called, which may result in a  <code>SecurityException</code> being raised (in the current thread).  <p> If this thread is different from the current thread (that is, the current thread is trying to stop a thread other than itself) or <code>obj</code> is not an instance of <code>ThreadDeath</code>, the security manager's <code>checkPermission</code> method (with the <code>RuntimePermission("stopThread")</code> argument) is called in addition. Again, 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.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>obj</CODE> - the Throwable object to be thrown.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if the current thread cannot modify               this thread.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Thread.html#interrupt()"><CODE>interrupt()</CODE></A>, <A HREF="../../java/lang/Thread.html#checkAccess()"><CODE>checkAccess()</CODE></A>, <A HREF="../../java/lang/Thread.html#run()"><CODE>run()</CODE></A>, <A HREF="../../java/lang/Thread.html#start()"><CODE>start()</CODE></A>, <A HREF="../../java/lang/Thread.html#stop()"><CODE>stop()</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkAccess(java.lang.Thread)"><CODE>SecurityManager.checkAccess(Thread)</CODE></A>, <A HREF="../../java/lang/SecurityManager.html#checkPermission(java.security.Permission)"><CODE>SecurityManager.checkPermission(java.security.Permission)</CODE></A></DL></DD></DL><HR><A NAME="interrupt()"><!-- --></A><H3>interrupt</H3><PRE>public void <B>interrupt</B>()</PRE><DL><DD>Interrupts 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>.<DD><DL></DL></DD><DD><DL><DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/SecurityException.html">SecurityException</A></CODE> - if the current thread cannot modify         this thread.</DL></DD></DL><HR><A NAME="interrupted()"><!-- --></A><H3>interrupted</H3><PRE>public static boolean <B>interrupted</B>()</PRE><DL><DD>Tests whether the current thread has been interrupted.  The <i>interrupted status</i> of the thread is cleared by this method.  In other words, if this method were to be called twice in succession, the second call would return false (unless the current thread were interrupted again, after the first call had cleared its interrupted status and before the second call had examined it).<DD><DL></DL></DD><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="../../java/lang/Thread.html#isInterrupted()"><CODE>isInterrupted()</CODE></A></DL></DD></DL><HR><A NAME="isInterrupted()"><!-- --></A><H3>isInterrupted</H3><PRE>public boolean <B>isInterrupted</B>()</PRE><DL><DD>Tests whether this thread has been interrupted.  The <i>interrupted status</i> of the thread is unaffected by this method.<DD><DL></DL></DD><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="../../java/lang/Thread.html#interrupted()"><CODE>interrupted()</CODE></A></DL></DD></DL><HR><A NAME="destroy()"><!-- --></A><H3>destroy</H3><PRE>public void <B>destroy</B>()</PRE><DL><DD>Destroys this thread, without any cleanup. Any monitors it has  locked remain locked. (This method is not implemented.)<DD><DL></DL></DD></DL><HR><A NAME="isAlive()"><!-- --></A><H3>isAlive</H3><PRE>public final boolean <B>isAlive</B>()</PRE><DL><DD>Tests if this thread is alive. A thread is alive if it has  been started and has not yet died.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD><code>true</code> if this thread is alive;          <code>false</code> otherwise.</DL></DD></DL><HR><A NAME="suspend()"><!-- --></A><H3>suspend</H3><PRE>public final void <B>suspend</B>()</PRE><DL>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -