Package java.util.concurrent

Examples of java.util.concurrent.Semaphore.availablePermits()


        try {
            comparisons.acquire();
        } catch (InterruptedException ie) {
            // check whether we were interrupted while still waiting for the
            // comparisons to finish
             if (comparisons.availablePermits() < 1) {
                throw new IllegalStateException(
                    "interrupted while waiting for word comparisons to finish",
                    ie);
             }
        }
View Full Code Here


            Assert.assertNull(cache.getCurrentData("/test/one"));
            semaphore.acquire();
            Assert.assertNull(cache2.getCurrentData("/test/one"));

            assertNoMoreEvents();
            Assert.assertEquals(semaphore.availablePermits(), 0);
        }
        finally
        {
            CloseableUtils.closeQuietly(cache2);
        }
View Full Code Here

            catch ( Exception ignore )
            {
                // ignore
            }

            Assert.assertTrue(semaphore.availablePermits() == 0);
            Assert.assertFalse(selector.hasLeadership());

            selector.requeue();
            Assert.assertTrue(timing.multiple(4).acquireSemaphore(semaphore));
        }
View Full Code Here

         // Release the semaphore to allow the threads to start work
         semaphore.release(count);

         // Sleep to ensure the threads get all the semaphore tickets
         while (semaphore.availablePermits() != 0) TestingUtil.sleepThread(100);

         // Reacquire the semaphore tickets; when we have them all
         // we know the threads are done
         for (int i = 0; i < count; i++)
         {
View Full Code Here

                                try
                                {
                                    if ( isFirst.compareAndSet(true, false) )
                                    {
                                        semaphore.release(THREAD_QTY - 1);
                                        while ( semaphore.availablePermits() > 0 )
                                        {
                                            Thread.sleep(100);
                                        }
                                    }
                                    else
View Full Code Here

                                try
                                {
                                    if ( isFirst.compareAndSet(true, false) )
                                    {
                                        semaphore.release(THREAD_QTY - 1);
                                        while ( semaphore.availablePermits() > 0 )
                                        {
                                            Thread.sleep(100);
                                        }
                                    }
                                    else
View Full Code Here

    public Set<AggregateNumericMetric> run() {
        log.info("Starting metrics data aggregation");
        Stopwatch stopwatch = Stopwatch.createStarted();
        Semaphore permits = new Semaphore(batchSize * parallelism);

        log.debug("Allocating " + permits.availablePermits() + " permits");

        int num1Hour = 0;
        int num6Hour = 0;
        int num24Hour = 0;
        try {
View Full Code Here

            public void run() {
                async.run();
            }
        });
        // drain checkpoint permits
        checkpoint.acquireUninterruptibly(checkpoint.availablePermits());
        // block NodeStore.retrieve()
        retrieve.acquireUninterruptibly();
        t.start();

        // wait until async update called checkpoint
View Full Code Here

         // Release the semaphore to allow the threads to start work
         semaphore.release(count);

         // Sleep to ensure the threads get all the semaphore tickets
         while (semaphore.availablePermits() != 0) TestingUtil.sleepThread(100);

         // Reacquire the semaphore tickets; when we have them all
         // we know the threads are done
         for (int i = 0; i < count; i++)
         {
View Full Code Here

                            try
                            {
                                if ( isFirst.compareAndSet(true, false) )
                                {
                                    semaphore.release(THREAD_QTY - 1);
                                    while ( semaphore.availablePermits() > 0 )
                                    {
                                        Thread.sleep(100);
                                    }
                                }
                                else
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.