try {
// first both threads get a lock, this one on res2
txMap1.put("key2", "value2");
synchronized (deadlockBarrier1) {
deadlockBarrier1.meet();
deadlockBarrier1.reset();
}
// if I am first, the other thread will be dead, i.e.
// exactly one
txMap1.put("key1", "value2");
txMap1.commitTransaction();