use of com.hazelcast.test.TestThread in project hazelcast by hazelcast.
the class CountDownLatchAdvancedTest method testLatchDestroyed.
@Test(expected = DistributedObjectDestroyedException.class)
public void testLatchDestroyed() throws Exception {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
HazelcastInstance hz1 = factory.newHazelcastInstance();
HazelcastInstance hz2 = factory.newHazelcastInstance();
final ICountDownLatch latch = hz1.getCountDownLatch("test");
latch.trySetCount(2);
new TestThread() {
public void doRun() throws Exception {
sleep(1000);
latch.destroy();
}
}.start();
hz2.getCountDownLatch("test").await(5, TimeUnit.SECONDS);
}
use of com.hazelcast.test.TestThread in project hazelcast by hazelcast.
the class ConditionAbstractTest method startThreadWaitingOnCondition.
private TestThread startThreadWaitingOnCondition(final ILock lock, final ICondition condition, final CountDownLatch awaited, final CountDownLatch signalled) {
TestThread t = new TestThread() {
public void doRun() throws Exception {
try {
lock.lock();
awaited.countDown();
condition.await();
signalled.countDown();
} finally {
lock.unlock();
}
}
};
t.start();
return t;
}
Aggregations