Possible Deadlock class B implements Runnable; { private Lock one, two; public(Lock one,Lock two) { this.one = one; this.two = two; } public void run() { try { two.lock(); doSomething(); one.lock(); doSomethingElse(); } finally { two.unlock(); one.unlock(); } } } class A implements Runnable; { private Lock one, two; public(Lock one,Lock two) { this.one = one; this.two = two; } public void run() { try { one.lock(); doSomething(); two.lock(); doSomethingElse(); } finally { two.unlock(); one.unlock(); } } } Deadlock possible depending on timing, but sometimes will not occur
{}