Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In the source code of <a href="http://www.docjar.com/html/api/java/lang/Thread.java.html" rel="nofollow">java.lang.Thread</a>, for the <code>interrupt</code> method the documentation clearly says:</p> <blockquote> <p>Interrupting a thread that is not alive need not have any effect.</p> </blockquote> <pre><code> 888 /** 889 * Interrupts this thread. 890 * 891 * &lt;p&gt; Unless the current thread is interrupting itself, which is 892 * always permitted, the {@link #checkAccess() checkAccess} method 893 * of this thread is invoked, which may cause a {@link 894 * SecurityException} to be thrown. 895 * 896 * &lt;p&gt; If this thread is blocked in an invocation of the {@link 897 * Object#wait() wait()}, {@link Object#wait(long) wait(long)}, or {@link 898 * Object#wait(long, int) wait(long, int)} methods of the {@link Object} 899 * class, or of the {@link #join()}, {@link #join(long)}, {@link 900 * #join(long, int)}, {@link #sleep(long)}, or {@link #sleep(long, int)}, 901 * methods of this class, then its interrupt status will be cleared and it 902 * will receive an {@link InterruptedException}. 903 * 904 * &lt;p&gt; If this thread is blocked in an I/O operation upon an {@link 905 * java.nio.channels.InterruptibleChannel &lt;/code&gt;interruptible 906 * channel&lt;code&gt;} then the channel will be closed, the thread's interrupt 907 * status will be set, and the thread will receive a {@link 908 * java.nio.channels.ClosedByInterruptException}. 909 * 910 * &lt;p&gt; If this thread is blocked in a {@link java.nio.channels.Selector} 911 * then the thread's interrupt status will be set and it will return 912 * immediately from the selection operation, possibly with a non-zero 913 * value, just as if the selector's {@link 914 * java.nio.channels.Selector#wakeup wakeup} method were invoked. 915 * 916 * &lt;p&gt; If none of the previous conditions hold then this thread's interrupt 917 * status will be set. &lt;/p&gt; 918 * 919 * &lt;p&gt; Interrupting a thread that is not alive need not have any effect. 920 * 921 * @throws SecurityException 922 * if the current thread cannot modify this thread 923 * 924 * @revised 6.0 925 * @spec JSR-51 926 */ 927 public void interrupt() { 928 if (this != Thread.currentThread()) 929 checkAccess(); 930 931 synchronized (blockerLock) { 932 Interruptible b = blocker; 933 if (b != null) { 934 interrupt0(); // Just to set the interrupt flag 935 b.interrupt(this); 936 return; 937 } 938 } 939 interrupt0(); 940 } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload