This code does not have race conditions, but the only algorithm that can detect this is Dinning-Schonberg.
Thread t1 = new Thread() { public void run() { synchronized (m1) { synchronized (m2) { a[0] += 1; } } } }; Thread t2 = new Thread() { public void run() { synchronized (m2) { synchronized (m3) { a[0] += 2; } } } }; Thread t3 = new Thread() { public void run() { synchronized (m1) { synchronized (m3) { a[0] += 3; } } } }; t1.start(); t2.start(); t3.start()
Back.