Package java.util.concurrent

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


    // from the current game, not the next one.
    // This method is not that clean but there's no other possible way
    // to deal with the issue.
    try
    {
      s.acquire();
    }
    catch (InterruptedException e)
    {
      throw new RuntimeException(e);
    }
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) {
                logger.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

                m_waitingForAcquire.incrementAndGet();
            }
        }

        if (semaphore != null) {
            semaphore.acquire();
            m_waitingForAcquire.decrementAndGet();
        }

        return;
    }
View Full Code Here

         MessageDispatcher disp = dispatchers[i % 2];
           
         runners[i] = new ClassLoaderLeakRunner(disp, numLoops, runnerGroup, semaphore);        
      }

      semaphore.acquire(numThreads);
     
      for (int i = 0; i < runners.length; i++)
      {
         runners[i].start();
      }
View Full Code Here

               assertNull(cache2.get("/a/b/c", "age"));// must be null as not yet committed
               cache2.put("/a/b/c", "age", 40);

               threadTwoFirstPart.release();

               threadOneSecondPart.acquire();
               assertEquals(40, cache2.get("/a/b/c", "age"));// must not be null
               tm.commit();

               tm = beginTransaction();
               assertEquals("After cache2 commit", 40, cache2.get("/a/b/c", "age"));
View Full Code Here

      long start = System.currentTimeMillis();
      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[cacheCount];
      try
      {
         // Create a semaphore and take all its tickets
         Semaphore semaphore = new Semaphore(cacheCount);
         semaphore.acquire(cacheCount);

         // Create activation threads that will block on the semaphore
         CacheSPI[] caches = new CacheSPI[cacheCount];
         for (int i = 0; i < cacheCount; 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

         */
        if (!getController().isPrimitive() ) {
          Semaphore completionSemaphore = threadCompletionMonitor.get();
          try {
            //  Block until the CAS is fully processed or there is an error
            completionSemaphore.acquire();
          } catch( InterruptedException ex) {
          } finally {
            //  remove ThreadLocal semaphore
            threadCompletionMonitor.remove();
          }
View Full Code Here

              log.log(Level.WARNING, "Failed to reload the current webapp context.", ex);
            }
          }
        } finally {
          try {
            semaphore.acquire(MAX_SIMULTANEOUS_API_CALLS);
          } catch (InterruptedException ex) {
            log.log(Level.WARNING, "Interrupted while waiting for API calls to complete:", ex);
          }
          env.callRequestEndListeners();
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.