Examples of tryAcquire()


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

                Thread.sleep(1000);
            }
        }

        // Wait until all updates return
        if(!sem.tryAcquire(ClientBase.CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS)) {
            LOG.warn("Did not aquire semaphore fast enough");
        }
        mytestfooThread.join(ClientBase.CONNECTION_TIMEOUT);
        if (mytestfooThread.isAlive()) {
            LOG.error("mytestfooThread is still alive");

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

      }
    };
    final String type = "test";
    engine.addMessageListener(type, listener);
    engine.send(new TestMessage<String>(type, expectedBody));
    lock.tryAcquire(3, TimeUnit.SECONDS);
    assertEquals(expectedBody, actualBody.toString());
    engine.stop();
  }

  @Test(timeout = 1000)

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

    engine.addMessageListener(type, listener);
    final int totalMessages = 1000;
    for (int i = 0; i < totalMessages; i++) {
      engine.send(message);
    }
    lock.tryAcquire(totalMessages, 3, TimeUnit.SECONDS);
    assertEquals(totalMessages, counter.get());
    engine.stop();
  }

  @Test(timeout = 1000)

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

    engine.addMessageListener(type, listenerB);
    final int totalMessages = 1000;
    for (int i = 0; i < totalMessages; i++) {
      engine.send(message);
    }
    lock.tryAcquire(totalMessages * 2, 3, TimeUnit.SECONDS);
    assertEquals(totalMessages * 2, counter.get());
    engine.stop();
  }

  @Test

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

            for (int i = 0; i < configs.length; i++) {
                configs[i].delete();
            }

            if (!sem.tryAcquire(1, TimeUnit.SECONDS)) {
                throw new IOException("Not all instances were removed in time.");
            }
            tracker.close();
        }
    }

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

            for (int i = 0; i < configs.length; i++) {
                configs[i].delete();
            }

            if (!sem.tryAcquire(1, TimeUnit.SECONDS)) {
                throw new IOException("Not all instances were removed in time.");
            }
            tracker.close();
        }
    }

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

            };
            tracker.open();

            configs[0].delete();

            if (!sem.tryAcquire(1, TimeUnit.SECONDS)) {
                throw new IOException("Instance did not get removed in time.");
            }
        }
    }

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

            // there is no limit, always allow it
            permit.name = null;
            return permit;
        }

        boolean permitted = semaphore.tryAcquire();

        if (!permitted) {
            int deniedCount = getDeniedCount(name).incrementAndGet(); // don't worry about this not being atomic with aquire, no biggie
            long sleepBeforeRetry = getSleepBeforeRetryHint(deniedCount);
            throw new NotPermittedException(sleepBeforeRetry);

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

                sem.release();
            }
        }.start();

        // wait for the reading to be done
        sem.tryAcquire(5, TimeUnit.SECONDS);

        request = m_cachedRepository.getRequest(true);
        assert request[0].equals("checkout");

        // inspect the current contents of impl

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

     
      semaphore.release(numThreads);
     
      try
      {
         assertTrue("messages received within 15 seconds", semaphore.tryAcquire(numThreads, 15, TimeUnit.SECONDS));
        
         log.info("Messages received");
      }
      finally
      {
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.