다음을 통해 공유


Thread.Interrupt Method

Definition

Interrupts this thread.

[Android.Runtime.Register("interrupt", "()V", "GetInterruptHandler")]
public virtual void Interrupt ();
[<Android.Runtime.Register("interrupt", "()V", "GetInterruptHandler")>]
abstract member Interrupt : unit -> unit
override this.Interrupt : unit -> unit
Attributes

Remarks

Interrupts this thread.

Unless the current thread is interrupting itself, which is always permitted, the #checkAccess() checkAccess method of this thread is invoked, which may cause a SecurityException to be thrown.

If this thread is blocked in an invocation of the Object#wait() wait(), Object#wait(long) wait(long), or Object#wait(long, int) wait(long, int) methods of the Object class, or of the #join(), #join(long), #join(long, int), #sleep(long), or #sleep(long, int), methods of this class, then its interrupt status will be cleared and it will receive an InterruptedException.

If this thread is blocked in an I/O operation upon an java.nio.channels.InterruptibleChannel InterruptibleChannel then the channel will be closed, the thread's interrupt status will be set, and the thread will receive a java.nio.channels.ClosedByInterruptException.

If this thread is blocked in a java.nio.channels.Selector then the thread's interrupt status will be set and it will return immediately from the selection operation, possibly with a non-zero value, just as if the selector's java.nio.channels.Selector#wakeup wakeup method were invoked.

If none of the previous conditions hold then this thread's interrupt status will be set.

Interrupting a thread that is not alive need not have any effect.

Java documentation for java.lang.Thread.interrupt().

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also