Package java.util.concurrent

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


       
        rsaList.add(rsa);
       
        tm.triggerExportImportForRemoteSericeAdmin(rsa);
       
        assertTrue(sema.tryAcquire(10, TimeUnit.SECONDS));
       
       
        tm.stop();
       
        c.verify();
View Full Code Here


                semaphore.release();
            }
        }.start();
        m_repository.writeLocal(in);
        try {
            if (!semaphore.tryAcquire(30, TimeUnit.SECONDS)) {
                throw new IOException("Error writing the contents of RepositoryUserAdmin.");
            }
        }
        catch (InterruptedException e) {
            Thread.currentThread().interrupt();
View Full Code Here

                     }

                     message.getBodyBuffer().writeBytes(new byte[50]);

                     producer.send(message);
                     assertTrue(semop.tryAcquire(1, 10, TimeUnit.SECONDS));
                  }
               }
               catch (Throwable e)
               {
                  e.printStackTrace(System.out);
View Full Code Here

          try {
            s.acquire();
          } catch (InterruptedException ix) {}
        } else {
          try {
            s.tryAcquire(graceperiod, TimeUnit.MILLISECONDS);
          } catch (InterruptedException ix) {}
        }
      }
      result = bpcRef.get();
      st.close();
View Full Code Here

        creationSemaphore = new Semaphore(1, true);
        socketCreationMap.put(key, creationSemaphore);
      }
    }
    try {
      boolean retval = creationSemaphore.tryAcquire(10, TimeUnit.SECONDS);
      if (!retval) {
        throw new IOException("Could not acquire IO Semaphore'" + key
            + "' after 10 seconds -- giving up ");
      }
    } catch (InterruptedException e) {
View Full Code Here

                semaphore.drainPermits();
                _semaphores.putIfAbsent(thread, semaphore);
            }
            semaphore = _semaphores.get(thread);
            try {
                semaphore.tryAcquire(timeout, TimeUnit.MILLISECONDS);
            } catch (InterruptedException exception) {
                logger.log(Level.FINER, "Exception ", exception);
            }
        }
View Full Code Here

                int next = random.nextInt(100);
                countList.add(next);
                count.setCount(next);

                Assert.assertTrue(semaphore.tryAcquire(CLIENT_QTY, 10, TimeUnit.SECONDS));
            }
            count.setCount(-1);

            for ( Future<List<Integer>> future : futures )
            {
View Full Code Here

                creationSemaphore = new Semaphore(1, true);
                socketCreationMap.put(key, creationSemaphore);
            }
        }
        try {
            boolean retval = creationSemaphore.tryAcquire(10, TimeUnit.SECONDS);
            if (!retval) {
                throw new IOException("Could not acquire IO Semaphore'" + key
                        + "' after 10 seconds -- giving up ");
            }
        } catch (InterruptedException e) {
View Full Code Here

            }
        }
        s.release(notOwnedCount);
        try {
            if (ok.get()) {
                return s.tryAcquire(partitionCount, 10, TimeUnit.SECONDS) && ok.get();
            } else {
                return false;
            }
        } catch (InterruptedException ignored) {
            return false;
View Full Code Here

         // Reacquire the semaphore tickets; when we have them all
         // we know the threads are done
         for (int i = 0; i < count; i++)
         {
            boolean acquired = semaphore.tryAcquire(60, TimeUnit.SECONDS);
            if (!acquired) fail("failed to acquire semaphore " + i);
         }

         // allow any async calls to clear
         if (!sync)
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.