@Test
public void testConcurrency() throws IOException, KeeperException,
    InterruptedException {

  ZooKeeperCounter seq = new ZooKeeperCounter(svc, "/seq-generator-conc-test");
  CounterThread t1 = new CounterThread(seq);
  CounterThread t2 = new CounterThread(seq);
  t1.start();
  t2.start();
  t1.join();
  t2.join();
  
  long last = -1;
  for (Long l : t1.counts) {
    assertTrue("Expected increasing counts", last < l);
    last = l;
  }
  last = -1;
  for (Long l : t2.counts) {
    assertTrue("Expected increasing counts", last < l);
    last = l;
  }
  
  ArrayList<Long> counts = t1.counts;    
  counts.addAll(t2.counts);
  Collections.sort(counts);
  for (long i = 0; i < LOOP_COUNT * 2; ++i) {
    assertEquals("Missing counter value", i, (long) counts.get((int) i));
  }
  seq.shutdown();
}