@Test
public void testThreads() throws Exception
{

    final int THREAD_QTY = 10;
    Timing timing = new Timing();
    CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1));
    client.start();
    try
    {
        final InterProcessSemaphoreV2 semaphore = new InterProcessSemaphoreV2(client, "/test", 1);
        ExecutorService service = Executors.newFixedThreadPool(THREAD_QTY);
        for ( int i = 0; i < THREAD_QTY; ++i )
        {
            service.submit
                (
                    new Callable<Object>()
                    {
                        @Override
                        public Object call() throws Exception
                        {
                            Lease lease = semaphore.acquire();
                            try
                            {
                                Thread.sleep(1);
                            }
                            finally
                            {
                                lease.close();
                            }
                            return null;
                        }
                    }
                );
        }
        service.shutdown();
        Assert.assertTrue(service.awaitTermination(10, TimeUnit.SECONDS));
    }
    finally
    {
        TestCleanState.closeAndTestClean(client);
    }
}