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

📄 javalang.doc18.html

📁 java语言规范
💻 HTML
📖 第 1 页 / 共 3 页
字号:
Otherwise, the priority of this <code>Thread</code> object is set to the smaller of the specified <code>newPriority</code> and the maximum permitted priority <a href="javalang.doc19.html#27398">(&#167;20.21.12)</a> of the thread's thread group <a href="javalang.doc18.html#2870">(&#167;20.20.21)</a>.<p>
<a name="2860"></a>
<p><font size=+1><strong>20.20.24   </strong> <code>public final boolean <code><b>isDaemon</b></code>()</code></font>
<p>
<a name="8429"></a>
The result is <code>true</code> if and only if this thread is marked as a daemon thread.
<p><a name="2861"></a>
<p><font size=+1><strong>20.20.25   </strong> <code>public final void <code><b>setDaemon</b></code>(boolean on)<br>throws SecurityException, IllegalThreadStateException</code></font>
<p>
<a name="8359"></a>
First, the <code>checkAccess</code> method <a href="javalang.doc18.html#8265">(&#167;20.20.12)</a> of this <code>Thread</code> object is called with 
no arguments. This may result in throwing a <code>SecurityException</code> (in the current 
thread).
<p><a name="8436"></a>
If this thread is alive, an <code>IllegalThreadStateException</code> is thrown. Otherwise, this thread is marked as being a daemon thread if the argument is <code>true</code>, and as not being a daemon thread if the argument is <code>false</code>.<p>
<a name="8259"></a>
<p><font size=+1><strong>20.20.26   </strong> <code>public final boolean <code><b>isAlive</b></code>()</code></font>
<p>
<a name="8441"></a>
The result is <code>true</code> if and only if this thread is alive (it has been started and has not 
yet died).
<p><a name="14182"></a>
<p><font size=+1><strong>20.20.27   </strong> <code>public int <code><b>countStackFrames</b></code>()</code></font>
<p>
<a name="26530"></a>
This method returns the number of Java Virtual Machine stack frames currently 
active for this thread.
<p><a name="2773"></a>
<p><font size=+1><strong>20.20.28   </strong> <code>public final void <code><b>join</b></code>() 	throws InterruptedException</code></font>
<p>
<a name="26418"></a>
This method causes the current thread to wait (using the <code>wait</code> method <a href="javalang.doc1.html#33394">(&#167;20.1.6)</a> of 
class <code>Object</code>) until this thread is no longer alive.
<p><a name="29128"></a>
If the current thread is interrupted <a href="javalang.doc18.html#29179">(&#167;20.20.31)</a> by another thread while it is waiting, then the wait is ended and an <code>InterruptedException</code> is thrown.<p>
<a name="14183"></a>
<p><font size=+1><strong>20.20.29   </strong> <code>public final void <code><b>join</b></code>(long millis)<br>	throws InterruptedException</code></font>
<p>
<a name="26423"></a>
This method causes the current thread to wait (using the <code>wait</code> method <a href="javalang.doc1.html#14926">(&#167;20.1.7)</a> of 
class <code>Object</code>) until either this thread is no longer alive or a certain amount of real 
time has elapsed, more or less.
<p><a name="26603"></a>
The amount of real time, measured in milliseconds, is given by <code>millis</code>. If <code>millis</code> is zero, however, then real time is not taken into consideration and this method simply waits until this thread is no longer alive.<p>
<a name="29141"></a>
If the current thread is interrupted <a href="javalang.doc18.html#29179">(&#167;20.20.31)</a> by another thread while it is waiting, then the wait is ended and an <code>InterruptedException</code> is thrown.<p>
<a name="14185"></a>
<p><font size=+1><strong>20.20.30   </strong> <code>public final void <code><b>join</b></code>(long millis, int nanos)<br>	throws InterruptedException</code></font>
<p>
<a name="26522"></a>
This method causes the current thread to wait (using the <code>wait</code> method <a href="javalang.doc1.html#32520">(&#167;20.1.8)</a> of 
class <code>Object</code>) until either this thread is no longer alive or a certain amount of real 
time has elapsed, more or less.
<p><a name="26604"></a>
The amount of real time, measured in nanoseconds, is given by:<p>
<pre><a name="26525"></a><code>1000000*millis+nanos
</code></pre><a name="29145"></a>
In all other respects, this method does the same thing as the method <code>join</code> of one 
argument <a href="javalang.doc18.html#14183">(&#167;20.20.29)</a>. In particular, <code>join(0,</code> <code>0)</code> means the same thing as 
<code>join(0)</code>.
<p><a name="31401"></a>
If the current thread is interrupted <a href="javalang.doc18.html#29179">(&#167;20.20.31)</a> by another thread while it is waiting, then the wait is ended and an <code>InterruptedException</code> is thrown.<p>
<a name="29179"></a>
<p><font size=+1><strong>20.20.31   </strong> <code>public void <code><b>interrupt</b></code>()</code></font>
<p>
<a name="29191"></a>
An interrupt request is posted for this thread. This thread does not necessarily 
react immediately to the interrupt, however. If this thread is waiting, it is awakened
and it then throws an <code>InterruptedException</code>.
<p><a name="29217"></a>
[This method is scheduled for introduction in Java version 1.1.]<p>
<a name="29183"></a>
<p><font size=+1><strong>20.20.32   </strong> <code>public boolean <code><b>isInterrupted</b></code>()</code></font>
<p>
<a name="29196"></a>
The result is <code>true</code> if and only if an interrupt request has been posted for this 
thread.
<p><a name="29223"></a>
[This method is scheduled for introduction in Java version 1.1.]<p>
<a name="29184"></a>
<p><font size=+1><strong>20.20.33   </strong> <code>public static boolean <code><b>interrupted</b></code>()</code></font>
<p>
<a name="29198"></a>
The result is <code>true</code> if and only if an interrupt request has been posted for the current
thread.
<p><a name="29227"></a>
[This method is scheduled for introduction in Java version 1.1.]<p>
<a name="26543"></a>
<p><font size=+1><strong>20.20.34   </strong> <code>public static Thread <code><b>currentThread</b></code>()</code></font>
<p>
<a name="26552"></a>
The <code>Thread</code> object that represents the current thread is returned.
<p><a name="26411"></a>
<p><font size=+1><strong>20.20.35   </strong> <code>public static int <code><b>activeCount</b></code>()</code></font>
<p>
<a name="26533"></a>
This method returns the number of active threads in the thread group to which the 
current thread belongs. This count includes threads in subgroups of that thread 
group. This is the same as the value of the expression:
<p><pre><a name="26534"></a>Threads.currentThread().getThreadGroup().activeCount()
</pre><a name="29232"></a>
[This method is deprecated for use in new code after Java version 1.1 becomes available. Instead, an expression equivalent to:<p>
<pre><a name="29252"></a>Threads.currentThread().getThreadGroup().allThreadsCount()
</pre><a name="29250"></a>
should be used. See the method <code>allThreadsCount</code> of class <code>ThreadGroup</code>.]
<p><a name="26412"></a>
<p><font size=+1><strong>20.20.36   </strong> <code>public static int <code><b>enumerate</b></code>(Thread tarray[])</code></font>
<p>
<a name="26556"></a>
The active threads in the thread group to which the current thread belongs, including
threads in subgroups of that thread group, are enumerated and their Thread 
objects are put into the array <code>tarray</code>. The number of threads actually put into the 
array is returned. Call this value <i>n</i>; then the threads have been put into elements <code>0</code> 
through <i>n</i><code>-1</code> of <code>tarray</code>. If the number of threads exceeds the length of <code>tarray</code>, 
then some of the threads, <code>tarray.length</code> of them, are chosen arbitrarily and 
used to fill the array <code>tarray</code>.
<p><a name="29267"></a>
[This method is deprecated for use in new code after Java version 1.1 becomes available. Instead, an expression equivalent to:<p>
<pre><a name="29268"></a>Threads.currentThread().getThreadGroup().allThreads()
</pre><a name="29269"></a>
should be used. See the method <code>allThreads</code> of class <code>ThreadGroup</code>.]
<p><a name="14189"></a>
<p><font size=+1><strong>20.20.37   </strong> <code>public static void <code><b>dumpStack</b></code>()</code></font>
<p>
<a name="26581"></a>
This is a utility method that makes it easy to print a stack dump for the current 
thread. It is equivalent in effect to:
<p><pre><a name="26582"></a>new Exception("Stack trace").printStackTrace()
</pre><a name="26587"></a>
See the <code>printStackTrace</code> method <a href="javalang.doc20.html#10058">(&#167;20.22.6)</a> of class <code>Throwable</code>.
<p><a name="2706"></a>
<p><font size=+1><strong>20.20.38   </strong> <code>public static void <code><b>yield</b></code>()</code></font>
<p>
<a name="26594"></a>
This method causes the current thread to yield, allowing the thread scheduler to 
choose another runnable thread for execution.
<p><a name="2707"></a>
<p><font size=+1><strong>20.20.39   </strong> <code>public static void <code><b>sleep</b></code>(long millis)<br>throws InterruptedException</code></font>
<p>
<a name="26610"></a>
This method causes the current thread to yield and not to be scheduled for further 
execution until a certain amount of real time has elapsed, more or less.
<p><a name="26611"></a>
The amount of real time, measured in milliseconds, is given by <code>millis</code>.<p>
<a name="29149"></a>
If the current thread is interrupted <a href="javalang.doc18.html#29179">(&#167;20.20.31)</a> by another thread while it is waiting, then the sleep is ended and an <code>InterruptedException</code> is thrown.<p>
<a name="2708"></a>
<p><font size=+1><strong>20.20.40   </strong> <code>public static void <code><b>sleep</b></code>(long millis, int nanos)<br>throws InterruptedException</code></font>
<p>
<a name="26625"></a>
This method causes the current thread to yield and not to be scheduled for further 
execution until a certain amount of real time has elapsed, more or less.
<p><a name="31430"></a>
The amount of real time, measured in nanoseconds, is given by:<p>
<pre><a name="31431"></a><code>1000000*millis+nanos
</code></pre><a name="32781"></a>
In all other respects, this method does the same thing as the method <code>sleep</code> of one 
argument <a href="javalang.doc18.html#2707">(&#167;20.20.39)</a>. In particular, <code>sleep(0,</code> <code>0)</code> means the same thing as 
<code>sleep(0)</code>.
<p><a name="29157"></a>
If the current thread is interrupted <a href="javalang.doc18.html#29179">(&#167;20.20.31)</a> by another thread while it is waiting, then the sleep is ended and an <code>InterruptedException</code> is thrown.<p>
<a name="52173"></a>
<p><font size=+1><strong>20.20.41   </strong> <code>public void <strong>destroy</strong>()<br>throws SecurityException</code></font>
<p>
<a name="52177"></a>
First, the <code>checkAccess</code> method <a href="javalang.doc18.html#8265">(&#167;20.20.12)</a> of this <code>Thread</code> object is called with 
no arguments. This may result in throwing a <code>SecurityException</code> (in the current 
thread).
<p><a name="52178"></a>
Then destroys this thread, without any cleanup. Any monitors the thread has locked remain locked.<p>
<a name="52179"></a>
[This method is not implemented in early versions of Java, through 1.1.]<p>


<hr>
<!-- This inserts footnotes--><p>
<a href="index.html">Contents</a> | <a href="javalang.doc17.html">Prev</a> | <a href="javalang.doc19.html">Next</a> | <a href="j.index.doc1.html">Index</a>
<p>
<font size=-1>Java Language Specification (HTML generated by Suzette Pelouch on February 24, 1998)<br>
<i><a href="jcopyright.doc.html">Copyright &#169 1996 Sun Microsystems, Inc.</a>
All rights reserved</i>
<br>
Please send any comments or corrections to <a href="mailto:doug.kramer@sun.com">doug.kramer@sun.com</a>
</font>
</body></html>

⌨️ 快捷键说明

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