Package java.util.concurrent

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


            // we acquire it in the thread to avoid blocking other messages with a different call id
            // that could be processed in parallel                                   
            Semaphore semaphore = callIDOrderingStructure.getSemaphore();
            final Queue<SIPMessage> messagesForCallID = callIDOrderingStructure.getMessagesForCallID();
            try {                                                                               
                semaphore.acquire();                                       
            } catch (InterruptedException e) {
                sipStack.getStackLogger().logError("Semaphore acquisition for callId " + callId + " interrupted", e);
            }
            // once acquired we get the first message to process
            SIPMessage message = messagesForCallID.poll();
View Full Code Here


      try
      {
         // Create a semaphore and take all its tickets
         Semaphore semaphore = new Semaphore(count);
         semaphore.acquire(count);

         // Create activation threads that will block on the semaphore
         CacheSPI[] caches = new CacheSPI[count];
         for (int i = 0; i < count; i++)
         {
View Full Code Here

      StaggeredWebDeployerActivator[] activators = new StaggeredWebDeployerActivator[count];
      try
      {
         // Create a semaphore and take all its tickets
         Semaphore semaphore = new Semaphore(count);
         semaphore.acquire(count);

         // Create activation threads that will block on the semaphore
         CacheSPI[] caches = new CacheSPI[count];
         for (int i = 0; i < count; i++)
         {
View Full Code Here

         CacheSPI[] caches = new CacheSPI[count + 1];
         caches[0] = cacheA;

         // Create a semaphore and take all its tickets
         Semaphore semaphore = new Semaphore(count);
         semaphore.acquire(count);

         // Create stressor threads that will block on the semaphore

         for (int i = 0; i < count; i++)
         {
View Full Code Here

         public void run()
         {
            try
            {
               sem.acquire(); // we're first to the semaphore

               // log("waiting on barrier");
               barrier.await(); // wait until t2 joins us
               // log("passed barrier");
               lock = s.readLock();
View Full Code Here

               log("1st read: value is " + value);
               assertEquals(10, value);
               sem.release(); // give t2 time to make the modification
               TestingUtil.sleepThread(100);

               sem.acquire(); // to read the uncommitted modification by t2
               log("2nd read: value is " + value + "; we should see t2's uncommitted change (20)");
               assertEquals(20, value); // we're seeing the modification by t2 before t2 committed (a.k.a. released the lock)
               sem.release();
               TestingUtil.sleepThread(100);
View Full Code Here

               log("2nd read: value is " + value + "; we should see t2's uncommitted change (20)");
               assertEquals(20, value); // we're seeing the modification by t2 before t2 committed (a.k.a. released the lock)
               sem.release();
               TestingUtil.sleepThread(100);

               sem.acquire(); // to read the committed change by t2
               log("3rd read: value is still " + value + "; we should see t2's committed change");
               assertEquals(20, value);
            }
            catch (Throwable ex)
            {
View Full Code Here

         {
            try
            {
               TestingUtil.sleepThread(100);
               barrier.await();
               sem.acquire();
               lock = s.writeLock();
               lock.tryLock(TIMEOUT, TimeUnit.MILLISECONDS);
               log("changing value from " + value + " to 20");
               value = 20;
               sem.release(); // now t1 can read the uncommitted modification
View Full Code Here

               log("changing value from " + value + " to 20");
               value = 20;
               sem.release(); // now t1 can read the uncommitted modification
               TestingUtil.sleepThread(100);

               sem.acquire(); // to unlock the lock
               log("committing the TX");
               lock.unlock();
            }
            catch (Throwable ex)
            {
View Full Code Here

            final Queue<SIPMessage> messagesForCallID = callIDOrderingStructure.getMessagesForCallID();
            if(sipStack.sipEventInterceptor != null) {
              sipStack.sipEventInterceptor.beforeMessage(messagesForCallID.peek());
            }
            try {                                                                               
                semaphore.acquire();                                       
            } catch (InterruptedException e) {
                sipStack.getStackLogger().logError("Semaphore acquisition for callId " + callId + " interrupted", e);
            }
            // once acquired we get the first message to process
            SIPMessage message = messagesForCallID.poll();
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.