本文整理了Java中java.lang.Thread.isInterrupted()
方法的一些代码示例,展示了Thread.isInterrupted()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Thread.isInterrupted()
方法的具体详情如下:
包路径:java.lang.Thread
类名称:Thread
方法名:isInterrupted
[英]Tests whether this thread has been interrupted. The interrupted status of the thread is unaffected by this method.
A thread interruption ignored because a thread was not alive at the time of the interrupt will be reflected by this method returning false.
[中]测试此线程是否已中断。线程的中断状态不受此方法的影响。
由于线程在中断时不处于活动状态而被忽略的线程中断将通过返回false的方法反映出来。
代码示例来源:origin: spring-projects/spring-framework
private void interruptIfNecessary() {
Thread currentReceiveThread = this.currentReceiveThread;
if (currentReceiveThread != null && !currentReceiveThread.isInterrupted()) {
currentReceiveThread.interrupt();
}
}
代码示例来源:origin: ReactiveX/RxJava
@Override
public void accept(Throwable e) throws Exception {
interrupted.set(Thread.currentThread().isInterrupted());
cdl.countDown();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public void run() throws Exception {
interrupted.set(Thread.currentThread().isInterrupted());
cdl.countDown();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public void accept(Throwable e) throws Exception {
interrupted.set(Thread.currentThread().isInterrupted());
cdl.countDown();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public void accept(Throwable e) throws Exception {
interrupted.set(Thread.currentThread().isInterrupted());
cdl.countDown();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public void accept(Throwable e) throws Exception {
interrupted.set(Thread.currentThread().isInterrupted());
cdl.countDown();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public void run() throws Exception {
interrupted.set(Thread.currentThread().isInterrupted());
cdl.countDown();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public void accept(Object v) throws Exception {
interrupted.set(Thread.currentThread().isInterrupted());
cdl.countDown();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public void accept(Object v) throws Exception {
interrupted.set(Thread.currentThread().isInterrupted());
cdl.countDown();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public void run() throws Exception {
interrupted.set(Thread.currentThread().isInterrupted());
cdl.countDown();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public void accept(Object v) throws Exception {
interrupted.set(Thread.currentThread().isInterrupted());
cdl.countDown();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public void run() throws Exception {
interrupted.set(Thread.currentThread().isInterrupted());
cdl.countDown();
}
});
代码示例来源:origin: google/guava
@Override
public void run() {
assertThat(Thread.currentThread().isInterrupted()).isFalse();
}
});
代码示例来源:origin: google/guava
@Override
public void run() {
terminated.set(shutdownAndAwaitTermination(service, 1L, SECONDS));
interrupted.set(Thread.currentThread().isInterrupted());
}
});
代码示例来源:origin: google/guava
@Override
public void run() {
assertThat(Thread.currentThread().isInterrupted()).isFalse();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public void accept(Object v, Throwable e) throws Exception {
assertNotNull(v);
assertNull(e);
interrupted.set(Thread.currentThread().isInterrupted());
cdl.countDown();
}
});
代码示例来源:origin: ReactiveX/RxJava
@Override
public void accept(Object v, Throwable e) throws Exception {
assertNull(v);
assertNotNull(e);
interrupted.set(Thread.currentThread().isInterrupted());
cdl.countDown();
}
});
代码示例来源:origin: google/guava
@GwtIncompatible // Thread.interrupt
public void testGetUnchecked_interrupted() {
Thread.currentThread().interrupt();
try {
assertEquals("foo", getUnchecked(immediateFuture("foo")));
assertTrue(Thread.currentThread().isInterrupted());
} finally {
Thread.interrupted();
}
}
代码示例来源:origin: google/guava
public void testGetCheckedUntimed_interrupted() {
SettableFuture<String> future = SettableFuture.create();
Thread.currentThread().interrupt();
try {
getChecked(future, TwoArgConstructorException.class);
fail();
} catch (TwoArgConstructorException expected) {
assertThat(expected).hasCauseThat().isInstanceOf(InterruptedException.class);
assertTrue(Thread.currentThread().isInterrupted());
} finally {
Thread.interrupted();
}
}
代码示例来源:origin: google/guava
public void testNoOpServiceStartStopAndWaitUninterruptible() throws Exception {
NoOpService service = new NoOpService();
currentThread().interrupt();
try {
service.startAsync().awaitRunning();
assertEquals(State.RUNNING, service.state());
service.stopAsync().awaitTerminated();
assertEquals(State.TERMINATED, service.state());
assertTrue(currentThread().isInterrupted());
} finally {
Thread.interrupted(); // clear interrupt for future tests
}
}
内容来源于网络,如有侵权,请联系作者删除!