public static boolean isLockOrderNormal(final Solution solution, final Object o1, final Object o2) throws Exception {
AtomicBoolean checkOrder = new AtomicBoolean(true);
Thread t1 = new Thread() {
@Override
public void run() {
synchronized (o1) {
try {
checkOrder.set(false);
Thread.sleep(1000);
} catch (InterruptedException e) {
}
}
}
};
Thread t2 = new Thread() {
@Override
public void run() {
solution.someMethodWithSynchronizedBlocks(o1, o2);
}
};
t1.start();
t2.start();
return checkOrder.get();
}
BlueJavaBanana
Level 37
My Solution works, but I'm not sure it should have passed - did I get lucky?
Under discussion
Comments
- Popular
- New
- Old
You must be signed in to leave a comment
This page doesn't have any comments yet