本文整理了Java中java.util.concurrent.CyclicBarrier.reset()
方法的一些代码示例,展示了CyclicBarrier.reset()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。CyclicBarrier.reset()
方法的具体详情如下:
包路径:java.util.concurrent.CyclicBarrier
类名称:CyclicBarrier
方法名:reset
[英]Resets the barrier to its initial state. If any parties are currently waiting at the barrier, they will return with a BrokenBarrierException. Note that resets after a breakage has occurred for other reasons can be complicated to carry out; threads need to re-synchronize in some other way, and choose one to perform the reset. It may be preferable to instead create a new barrier for subsequent use.
[中]将屏障重置为其初始状态。如果任何一方目前正在隔离墙等待,他们将返回BrokenBarrier例外。请注意,由于其他原因发生破损后的重置操作可能会比较复杂;线程需要以其他方式重新同步,并选择一种方式执行重置。最好是创建一个新的屏障,以供后续使用。
代码示例来源:origin: apache/ignite
@Override public void run() {
try {
barrier.await();
stopGrid(1);
barrier.await();
startGrid(1);
barrier.await();
}
catch (Exception e) {
e.printStackTrace();
barrier.reset();
}
}
});
代码示例来源:origin: apache/ignite
bar.reset();
代码示例来源:origin: apache/ignite
bar.reset();
代码示例来源:origin: apache/ignite
@Override public void run() {
try {
assertEquals(TOP_CHANGE_THREAD_CNT * 3, startedNodes.size());
for (String name : startedNodes) {
stopGrid(name, false);
awaitPartitionMapExchange();
}
startedNodes.clear();
sem.release(TOP_CHANGE_THREAD_CNT);
barrier.reset();
}
catch (Exception e) {
if (failed.compareAndSet(false, true)) {
sem.release(TOP_CHANGE_THREAD_CNT);
barrier.reset();
throw F.wrap(e);
}
}
}
});
代码示例来源:origin: hs-web/hsweb-framework
waitToReady.await();
waitToReady.reset();//重置,下一次循环继续等待
代码示例来源:origin: apache/hbase
t.join();
barrier.reset();
tasks.set(1000000);
t = new Thread(runnable);
代码示例来源:origin: apache/ignite
sem.release(TOP_CHANGE_THREAD_CNT);
barrier.reset();
代码示例来源:origin: apache/ignite
barrier.reset();
barrier.reset();
barrier.reset();
barrier.reset();
代码示例来源:origin: prestodb/presto
afterRequest.reset();
代码示例来源:origin: apache/hive
ready.reset();
代码示例来源:origin: apache/ignite
stop.set(true);
restartBarrier.reset();
代码示例来源:origin: apache/hive
ready.reset();
代码示例来源:origin: apache/hive
ready.reset();
completed.reset();
代码示例来源:origin: apache/ignite
putRmvOpBarrier.reset();
sizeOpBarrier.reset();
代码示例来源:origin: apache/ignite
putRmvOpBarrier.reset();
代码示例来源:origin: apache/ignite
putRmvOpBarrier.reset();
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Resets the barrier to its initial state. If any parties are
* currently waiting at the barrier, they will return with a
* {@link BrokenBarrierException}. Note that resets <em>after</em>
* a breakage has occurred for other reasons can be complicated to
* carry out; threads need to re-synchronize in some other way,
* and choose one to perform the reset. It may be preferable to
* instead create a new barrier for subsequent use.
*
* @param cause The cause of the BrokenBarrierException
*/
public synchronized void reset(Exception cause) {
if (!isBroken()) {
super.reset();
}
if (this.cause == null) {
this.cause = cause;
}
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
public void tick() {
logger.debug("send tick to reconnection work");
try {
barrier.await(60, TimeUnit.SECONDS);
} catch (Exception e) {
fail("Error while sending tick, no thread was waiting", e);
}
barrier.reset();
}
代码示例来源:origin: com.datastax.cassandra/cassandra-driver-core
public void tick() {
if (firstTick) firstTick = false;
else {
logger.debug("send tick to schedule");
try {
barrier.await(10, TimeUnit.SECONDS);
} catch (Exception e) {
fail("Error while sending tick, no thread was waiting", e);
}
barrier.reset();
}
}
}
代码示例来源:origin: spring-projects/spring-integration
@Test
public void testWithErrorChannel() throws Exception {
assertSame(this.errors, TestUtils.getPropertyValue(this.withErrorChannel, "errorChannel"));
service.n = 0;
MqttPahoMessageHandler adapter = new MqttPahoMessageHandler("tcp://localhost:1883", "si-test-out");
adapter.setDefaultTopic("mqtt-fooEx2");
adapter.setBeanFactory(mock(BeanFactory.class));
adapter.afterPropertiesSet();
adapter.start();
adapter.handleMessage(new GenericMessage<String>("foo"));
service.barrier.await(10, TimeUnit.SECONDS);
service.barrier.reset();
adapter.handleMessage(new GenericMessage<String>("foo"));
service.barrier.await(10, TimeUnit.SECONDS);
assertNotNull(errors.receive(10000));
service.barrier.reset();
adapter.stop();
}
内容来源于网络,如有侵权,请联系作者删除!