本文整理汇总了Java中sun.nio.ch.Interruptible类的典型用法代码示例。如果您正苦于以下问题:Java Interruptible类的具体用法?Java Interruptible怎么用?Java Interruptible使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Interruptible类属于sun.nio.ch包,在下文中一共展示了Interruptible类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: blockedOn
import sun.nio.ch.Interruptible; //导入依赖的package包/类
/** Set thread's blocker field. */
void blockedOn(Thread t, Interruptible b);
示例2: blockedOn
import sun.nio.ch.Interruptible; //导入依赖的package包/类
void blockedOn(Interruptible b) {
synchronized (blockerLock) {
blocker = b;
}
}
示例3: blockedOn
import sun.nio.ch.Interruptible; //导入依赖的package包/类
static void blockedOn(Interruptible intr) { // package-private
sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(),
intr);
}
示例4: blockedOn
import sun.nio.ch.Interruptible; //导入依赖的package包/类
static void blockedOn(Interruptible intr) { // package-private
SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(), intr);
}
示例5: blockedOn
import sun.nio.ch.Interruptible; //导入依赖的package包/类
private static void blockedOn(Interruptible interruptible) {
sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(), interruptible);
}
示例6: blockedOn
import sun.nio.ch.Interruptible; //导入依赖的package包/类
static void blockedOn(Interruptible intr) { // package-private
sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(), intr);
}
示例7: blockedOn
import sun.nio.ch.Interruptible; //导入依赖的package包/类
void blockedOn(Interruptible b) {
synchronized (blockerLock) {
blocker = b;
}
}
示例8: blockedOn
import sun.nio.ch.Interruptible; //导入依赖的package包/类
static void blockedOn(Interruptible intr) { // package-private
sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(),
intr);
}
示例9: interrupt
import sun.nio.ch.Interruptible; //导入依赖的package包/类
/**
* Interrupts this thread.
*
* <p> Unless the current thread is interrupting itself, which is
* always permitted, the {@link #checkAccess() checkAccess} method
* of this thread is invoked, which may cause a {@link
* SecurityException} to be thrown.
*
* <p> If this thread is blocked in an invocation of the {@link
* Object#wait() wait()}, {@link Object#wait(long) wait(long)}, or {@link
* Object#wait(long, int) wait(long, int)} methods of the {@link Object}
* class, or of the {@link #join()}, {@link #join(long)}, {@link
* #join(long, int)}, {@link #sleep(long)}, or {@link #sleep(long, int)},
* methods of this class, then its interrupt status will be cleared and it
* will receive an {@link InterruptedException}.
如果线程正处在waiting状态,那么它的中断状态将被清除,并收到一个InterruptedException异常
*
* <p> If this thread is blocked in an I/O operation upon an {@link
* java.nio.channels.InterruptibleChannel </code>interruptible
* channel<code>} then the channel will be closed, the thread's interrupt
* status will be set, and the thread will receive a {@link
* java.nio.channels.ClosedByInterruptException}.
*
* <p> If this thread is blocked in a {@link 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 {@link
* java.nio.channels.Selector#wakeup wakeup} method were invoked.
如果block在io操作上,那么中断状态将被设置,并且抛出相应异常。
*
* <p> If none of the previous conditions hold then this thread's interrupt
* status will be set. </p>
*
如果不是以上任何一种情况,那么线程的中断状态将被设置。
* <p> Interrupting a thread that is not alive need not have any effect.
*
* @throws SecurityException
* if the current thread cannot modify this thread
*
* @revised 6.0
* @spec JSR-51
*/
public void interrupt() {
if (this != Thread.currentThread())
checkAccess();
synchronized (blockerLock) {
//用来实现block在可中断io操作上的线程
Interruptible b = blocker;
if (b != null) {
interrupt0(); // Just to set the interrupt flag
b.interrupt(this);
return;
}
}
interrupt0();
}