private void concurrencyTest(final int nodeCount, boolean isFallback) throws Exception {
    final CuratorFramework curator = newCurator();
    ExecutorService executor = Executors.newFixedThreadPool(nodeCount);
    final CountDownLatch cdlIn = new CountDownLatch(nodeCount), cdlOut = new CountDownLatch(1);
    @SuppressWarnings("unchecked")
    FutureTask<SlotZnode>[] startTasks = new FutureTask[nodeCount];
    for (int i = 0; i < nodeCount; ++i) {
      if (isFallback) {
        curator.create().creatingParentsIfNeeded().forPath(PATH + "/worker-" + i);
      }
      final int ix = i;
      startTasks[i] = new FutureTask<SlotZnode>(new Callable<SlotZnode>() {
        SlotZnode node = createZnode(curator);
        public SlotZnode call() throws Exception {
          syncThreadStart(cdlIn, cdlOut);
          int id = System.identityHashCode(node);
          LOG.info("Starting the node " + id + " from task #" + ix);
          boolean result = node.start(30, TimeUnit.SECONDS);
          LOG.info((result ? "Started" : "Failed to start") + " the node from task #" + ix);
          return result ? node : null;
        }
      });
    }
    for (int i = 0; i < startTasks.length; ++i) {
      executor.execute(startTasks[i]);
    }
    cdlIn.await();
    cdlOut.countDown();
    boolean[] found = new boolean[nodeCount];
    int totalFallbackCount = 0;
    for (int i = 0; i < startTasks.length; ++i) {
      SlotZnode node = startTasks[i].get();
      assertNotNull("failed to start the node from task #" + i, node);
      totalFallbackCount += node.getFallbackCount();
      int slot = node.getCurrentSlot();
      assertTrue(slot < found.length);
      assertFalse(found[slot]); // Given these 2 lines we don't need to double check later.
      found[slot] = true;
    }
    if (isFallback) {
      LOG.info("Total fallback count " + totalFallbackCount);
      assertTrue(totalFallbackCount > 0);
    }
  }
See SlotZNode; some tests (and the setup) are c/p-ed or modified from Curator.
llap-client/src/test/org/apache/hadoop/hive/llap/registry/impl/TestSlotZnode.java