当前位置: 首页>>代码示例>>Java>>正文


Java Interruptible.interrupt方法代码示例

本文整理汇总了Java中sun.nio.ch.Interruptible.interrupt方法的典型用法代码示例。如果您正苦于以下问题:Java Interruptible.interrupt方法的具体用法?Java Interruptible.interrupt怎么用?Java Interruptible.interrupt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.nio.ch.Interruptible的用法示例。


在下文中一共展示了Interruptible.interrupt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
  }
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:59,代码来源:Thread.java

示例2: 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}.
 *
 * <p> If this thread is blocked in an I/O operation upon an {@link
 * 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 {@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.
 *
 * <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) {
        Interruptible b = blocker;
        if (b != null) {
            interrupt0();           // Just to set the interrupt flag
            b.interrupt(this);
            return;
        }
    }
    interrupt0();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:54,代码来源:Thread.java

示例3: 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}.
    *
    * <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.
    *
    * <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) {
    Interruptible b = blocker;
    if (b != null) {
	interrupt0();		// Just to set the interrupt flag
	b.interrupt();
	return;
    }
}
interrupt0();
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:54,代码来源:Thread.java

示例4: 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}.
 *
 * <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.
 *
 * <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) {
        Interruptible b = blocker;
        if (b != null) {
            interrupt0();           // Just to set the interrupt flag
            b.interrupt();
            return;
        }
    }
    interrupt0();
}
 
开发者ID:Matthewacon,项目名称:Octopressor,代码行数:54,代码来源:Thread.java

示例5: 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}.
 *
 * <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.
 *
 * <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) {
        Interruptible b = blocker;
        if (b != null) {
            interrupt0();           // Just to set the interrupt flag
            b.interrupt(this);
            return;
        }
    }
    interrupt0();
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:54,代码来源:Thread.java


注:本文中的sun.nio.ch.Interruptible.interrupt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。