@Test
  public void testSyncDeadlock() throws Exception {
    final Lock lock1 = new ReentrantLock();
    final Lock lock2 = new ReentrantLock();

    Thread thread1 = new Thread() {
      @Override
      public void run() {
        stuckThreads.add(Thread.currentThread());

        lock1.lock();

        Thread thread2 = new Thread() {
          @Override
          public void run() {
            stuckThreads.add(Thread.currentThread());
            lock2.lock();
            try {
              lock1.tryLock(10, TimeUnit.SECONDS);
            } catch (InterruptedException e) {
              // ignore
            }
            lock2.unlock();
          }
        };

        thread2.start();

        try {
          Thread.sleep(1000);
          lock2.tryLock(10, TimeUnit.SECONDS);
        } catch (InterruptedException ignore) {
        }

        lock1.unlock();
      }
    };

    thread1.start();

    Thread.sleep(2000);

    DeadlockDetector detector = new DeadlockDetector();
    detector.addDependencies(DeadlockDetector.collectAllDependencies("here"));
    LinkedList<Dependency> deadlocks = detector.findDeadlock();

    System.out.println("deadlocks=" + DeadlockDetector.prettyFormat(deadlocks));

    assertEquals(4, detector.findDeadlock().size());
  }
Make sure that we can detect a deadlock between two threads that are trying to acquire a two
different syncs in the different orders.
geode-core/src/integrationTest/java/org/apache/geode/distributed/internal/deadlock/DeadlockDetectorIntegrationTest.java