Package java.util.concurrent.locks

Examples of java.util.concurrent.locks.ReentrantLock.tryLock()


    try {
      if (fair || !lock.tryLock()) {
        boolean locked = false;
        do {
          try {
            locked = lock.tryLock(timeoutNanos, TimeUnit.NANOSECONDS);
            if (!locked) {
              return false;
            }
          } catch (InterruptedException interrupt) {
            interrupted = true;
View Full Code Here


      throws InterruptedException {
    if (guard.monitor != this) {
      throw new IllegalMonitorStateException();
    }
    final ReentrantLock lock = this.lock;
    if (!lock.tryLock(time, unit)) {
      return false;
    }

    boolean satisfied = false;
    try {
View Full Code Here

  public boolean tryEnterIf(Guard guard) {
    if (guard.monitor != this) {
      throw new IllegalMonitorStateException();
    }
    final ReentrantLock lock = this.lock;
    if (!lock.tryLock()) {
      return false;
    }

    boolean satisfied = false;
    try {
View Full Code Here

     * If lock is available, poll stale refs and remove them.
     * Called from ForkJoinPool when pools become quiescent.
     */
    static final void helpExpungeStaleExceptions() {
        final ReentrantLock lock = exceptionTableLock;
        if (lock.tryLock()) {
            try {
                expungeStaleExceptions();
            } finally {
                lock.unlock();
            }
View Full Code Here

       
       
        Future<Boolean> lockFuture = null;
       
        final ReentrantLock lock = getLocalLock(mutexName);
        final boolean lockedLocally = lock.tryLock();
        if (!lockedLocally) {
            this.logger.trace("local lock already held for {}", mutexName);
            return TryLockFunctionResultImpl.getSkippedInstance(LockStatus.SKIPPED_LOCKED);
        }
        try {
View Full Code Here

    * If lock is available, poll stale refs and remove them.
    * Called from ForkJoinPool when pools become quiescent.
    */
   static final void helpExpungeStaleExceptions() {
      final ReentrantLock lock = exceptionTableLock;
      if (lock.tryLock()) {
         try {
            expungeStaleExceptions();
         } finally {
            lock.unlock();
         }
View Full Code Here

      {
         return;
      }
     
      ReentrantLock lock = new ReentrantLock();
      if (lock.tryLock(500, TimeUnit.MILLISECONDS))
      {
         try
         {
            hotDeploymentStrategy = createHotDeployment(Thread.currentThread().getContextClassLoader(), isHotDeployEnabled(init));
           
View Full Code Here

    * If lock is available, poll stale refs and remove them.
    * Called from ForkJoinPool when pools become quiescent.
    */
   static final void helpExpungeStaleExceptions() {
      final ReentrantLock lock = exceptionTableLock;
      if (lock.tryLock()) {
         try {
            expungeStaleExceptions();
         } finally {
            lock.unlock();
         }
View Full Code Here

        dispatcher.registerHandler(socketTwo, new ZDispatcher.ZMessageHandler() {

            @Override
            public void handleMessage(ZDispatcher.ZSender sender, ZMsg msg) {
                try {
                    if (guardLock2.tryLock()) {
                        handlersBarrier.await(1, TimeUnit.SECONDS);
                    } else {
                        threadingIssueDetected.set(true);
                    }
                } catch (Exception ex) {
View Full Code Here

     * If lock is available, poll stale refs and remove them.
     * Called from ForkJoinPool when pools become quiescent.
     */
    static final void helpExpungeStaleExceptions() {
        final ReentrantLock lock = exceptionTableLock;
        if (lock.tryLock()) {
            try {
                expungeStaleExceptions();
            } finally {
                lock.unlock();
            }
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.