use of suite.concurrent.Mutex.MutexLock in project suite by stupidsing.
the class MutexTest method testNoDeadlock.
@Test
public void testNoDeadlock() throws InterruptedException {
Mutex a = new Mutex();
Mutex b = new Mutex();
MutexTestRunnable ra = () -> {
try (MutexLock mla = new MutexLock(a)) {
Thread_.sleepQuietly(500);
try (MutexLock mlb = new MutexLock(b)) {
}
}
};
MutexTestRunnable rb = () -> {
try (MutexLock mla = new MutexLock(a)) {
Thread_.sleepQuietly(500);
try (MutexLock mlb = new MutexLock(b)) {
}
}
};
assertFalse(isDeadlock(ra, rb));
}
use of suite.concurrent.Mutex.MutexLock in project suite by stupidsing.
the class MutexTest method testDeadlock.
@Test
public void testDeadlock() throws InterruptedException {
Mutex a = new Mutex();
Mutex b = new Mutex();
MutexTestRunnable ra = () -> {
try (MutexLock mla = new MutexLock(a)) {
Thread_.sleepQuietly(500);
try (MutexLock mlb = new MutexLock(b)) {
}
}
};
MutexTestRunnable rb = () -> {
try (MutexLock mlb = new MutexLock(b)) {
Thread_.sleepQuietly(500);
try (MutexLock mla = new MutexLock(a)) {
}
}
};
assertTrue(isDeadlock(ra, rb));
}