@Test(timeout = 40000)
  public void testDeadlockWhileUnmappingHosts() throws Exception {
    Provider<ClustersHostUnMapperThread> clustersHostUnMapperThreadFactory =
        new Provider<ClustersHostUnMapperThread>() {

      @Override
      public ClustersHostUnMapperThread get() {
        return new ClustersHostUnMapperThread();
      }
    };

    doLoadTest(new ClusterReaderThreadFactory(),
        clustersHostUnMapperThreadFactory,
        NUMBER_OF_THREADS,
        writerStoppedSignal,
        readerStoppedSignal);

    Assert.assertEquals(0,
        clusters.getHostsForCluster(CLUSTER_NAME).size());
  }
Tests that no deadlock exists when adding hosts while reading from the
cluster.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClustersDeadlockTest.java