@Test
  public void verifyMultipleListeners() throws Exception {
    DummyListenableFuture<String> future =
      new DummyListenableFuture<String>(false, service);

    final CountDownLatch latch = new CountDownLatch(2);
    final GenericCompletionListener listener1 =
      new GenericCompletionListener() {
        @Override
        public void onComplete(Future future) throws Exception {
          latch.countDown();
        }
      };

    final GenericCompletionListener listener2 =
      new GenericCompletionListener() {
        @Override
        public void onComplete(Future future) throws Exception {
          latch.countDown();
        }
      };

    future.addListener(listener1);
    future.addListener(listener2);

    future.set("Hello World");
    assertTrue(latch.await(1, TimeUnit.SECONDS));
  }
Use an unbounded thread pool for testing, which is very similar to
the one used in the {@link DefaultConnectionFactory}.
src/test/java/net/spy/memcached/internal/ListenableFutureTest.java