### Question:
DeadLock implements Runnable { DeadLock(CyclicBarrier barrier) { this.barrier = barrier; } DeadLock(CyclicBarrier barrier); void setOther(DeadLock other); @Override void run();  }### Answer:
@Ignore @Test public void deadLock() { CyclicBarrier barrier = new CyclicBarrier(2); DeadLock a = new DeadLock(barrier); DeadLock b = new DeadLock(barrier); a.setOther(b); b.setOther(a); Thread first = new Thread(a); Thread second = new Thread(b); first.start(); second.start(); try { second.join(); first.join(); } catch (InterruptedException e) { e.printStackTrace(); } }