sun.nio.ch.Interruptible Java Examples

The following examples show how to use sun.nio.ch.Interruptible. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Thread.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * 中断线程(只是给线程预设一个标记,不是立即让线程停下来)
 *
 * @throws SecurityException 若当前线程无法修改
 */
public void interrupt() {
    // 如果由别的线程对当前线程发起中断
    if (this != Thread.currentThread())
        checkAccess();

    synchronized (blockerLock) {
        Interruptible b = blocker;
        // 如果存在线程中断回调标记
        if (b != null) {
            // 设置中断标记
            interrupt0();
            b.interrupt(this);
            return;
        }
    }
    interrupt0();
}
 
Example #2
Source File: AbstractInterruptibleChannel.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
static void blockedOn(Interruptible intr) {         // package-private
    sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(),
                                                         intr);
}
 
Example #3
Source File: Thread.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
void blockedOn(Interruptible b) {
    synchronized (blockerLock) {
        blocker = b;
    }
}
 
Example #4
Source File: Thread.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
void blockedOn(Interruptible b) {
    synchronized (blockerLock) {
        blocker = b;
    }
}
 
Example #5
Source File: JavaLangAccess.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/** Set thread's blocker field. */
void blockedOn(Thread t, Interruptible b);
 
Example #6
Source File: AbstractInterruptibleChannel.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
static void blockedOn(Interruptible intr) {         // package-private
    sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(),
                                                         intr);
}
 
Example #7
Source File: AbstractInterruptibleChannel.java    From jdk-1.7-annotated with Apache License 2.0 4 votes vote down vote up
static void blockedOn(Interruptible intr) {         // package-private
    sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(),
                                                         intr);
}
 
Example #8
Source File: Thread.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
void blockedOn(Interruptible b) {
    synchronized (blockerLock) {
        blocker = b;
    }
}
 
Example #9
Source File: AbstractInterruptibleChannel.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
static void blockedOn(Interruptible intr) {         // package-private
    sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(),
                                                         intr);
}
 
Example #10
Source File: JavaLangAccess.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/** Set thread's blocker field. */
void blockedOn(Thread t, Interruptible b);
 
Example #11
Source File: AbstractInterruptibleChannel.java    From j2objc with Apache License 2.0 4 votes vote down vote up
static void blockedOn(Interruptible intr) {         // package-private
    // Android-changed: Call Thread.currentThread().blockedOn() directly.
    Thread.currentThread().blockedOn(intr);
}
 
Example #12
Source File: Thread.java    From j2objc with Apache License 2.0 4 votes vote down vote up
/** Set the IOBlocker field; invoked from java.nio code. */
public void blockedOn(Interruptible b) {
  synchronized (IOBlockerLock) {
    IOBlocker = b;
  }
}
 
Example #13
Source File: JobRunnerDelegate.java    From light-task-scheduler with Apache License 2.0 4 votes vote down vote up
private static void blockedOn(Interruptible interruptible) {
    sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(), interruptible);
}
 
Example #14
Source File: InterruptRead.java    From light-task-scheduler with Apache License 2.0 4 votes vote down vote up
static void blockedOn(Interruptible intr) { // package-private
    sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(), intr);
}
 
Example #15
Source File: Thread.java    From jdk-1.7-annotated with Apache License 2.0 4 votes vote down vote up
/**
   * 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();
  }
 
Example #16
Source File: JavaLangAccess.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/** Set thread's blocker field. */
void blockedOn(Thread t, Interruptible b);
 
Example #17
Source File: Thread.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
void blockedOn(Interruptible b) {
    synchronized (blockerLock) {
        blocker = b;
    }
}
 
Example #18
Source File: JavaLangAccess.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/** Set thread's blocker field. */
void blockedOn(Thread t, Interruptible b);
 
Example #19
Source File: AbstractInterruptibleChannel.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
static void blockedOn(Interruptible intr) {         // package-private
    sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(),
                                                         intr);
}
 
Example #20
Source File: Thread.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
void blockedOn(Interruptible b) {
    synchronized (blockerLock) {
        blocker = b;
    }
}
 
Example #21
Source File: JavaLangAccess.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/** Set thread's blocker field. */
void blockedOn(Thread t, Interruptible b);
 
Example #22
Source File: AbstractInterruptibleChannel.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
static void blockedOn(Interruptible intr) {         // package-private
    sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(),
                                                         intr);
}
 
Example #23
Source File: Thread.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
void blockedOn(Interruptible b) {
    synchronized (blockerLock) {
        blocker = b;
    }
}
 
Example #24
Source File: AbstractInterruptibleChannel.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
static void blockedOn(Interruptible intr) {         // package-private
    sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(),
                                                         intr);
}
 
Example #25
Source File: Thread.java    From Java8CN with Apache License 2.0 4 votes vote down vote up
void blockedOn(Interruptible b) {
    synchronized (blockerLock) {
        blocker = b;
    }
}
 
Example #26
Source File: JavaLangAccess.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/** Set thread's blocker field. */
void blockedOn(Thread t, Interruptible b);
 
Example #27
Source File: AbstractInterruptibleChannel.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
static void blockedOn(Interruptible intr) {         // package-private
    sun.misc.SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(),
                                                         intr);
}
 
Example #28
Source File: Thread.java    From jdk1.8-source-analysis with Apache License 2.0 4 votes vote down vote up
void blockedOn(Interruptible b) {
    synchronized (blockerLock) {
        blocker = b;
    }
}
 
Example #29
Source File: AbstractInterruptibleChannel.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
static void blockedOn(Interruptible intr) {         // package-private
    SharedSecrets.getJavaLangAccess().blockedOn(Thread.currentThread(), intr);
}
 
Example #30
Source File: Thread.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
void blockedOn(Interruptible b) {
    synchronized (blockerLock) {
        blocker = b;
    }
}