Package java.util.concurrent.locks

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


                        try
                        {
                            try
                            {
                                lockedFromClient[0] = deploymentLock.tryLock(1000, TimeUnit.MILLISECONDS);
                            }
                            catch (InterruptedException e)
                            {
                                // Ignore
                            }
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

     * 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

        /**
         * Interrupt thread if not running a task
         */
        void interruptIfIdle() {
            final ReentrantLock runLock = this.runLock;
            if (runLock.tryLock()) {
                try {
                    thread.interrupt();
                } finally {
                    runLock.unlock();
                }
View Full Code Here

    }

    @Override
    public Object acquireLockIfAvailable(Order order) {
        ReentrantLock lockObject = getSessionLock();
        boolean locked = lockObject.tryLock();
        return locked ? lockObject : null;
    }

    @Override
    public void releaseLock(Object lockObject) {
View Full Code Here

   * @return whether the monitor was entered
   */
  public boolean enter(long time, TimeUnit unit) {
    long timeoutNanos = unit.toNanos(time);
    final ReentrantLock lock = this.lock;
    if (!fair && lock.tryLock()) {
      return true;
    }
    long deadline = System.nanoTime() + timeoutNanos;
    boolean interrupted = Thread.interrupted();
    try {
View Full Code Here

    long deadline = System.nanoTime() + timeoutNanos;
    boolean interrupted = Thread.interrupted();
    try {
      while (true) {
        try {
          return lock.tryLock(timeoutNanos, TimeUnit.NANOSECONDS);
        } catch (InterruptedException interrupt) {
          interrupted = true;
          timeoutNanos = deadline - System.nanoTime();
        }
      }
View Full Code Here

    if (guard.monitor != this) {
      throw new IllegalMonitorStateException();
    }
    final ReentrantLock lock = this.lock;
    boolean reentrant = lock.isHeldByCurrentThread();
    if (fair || !lock.tryLock()) {
      long deadline = System.nanoTime() + timeoutNanos;
      if (!lock.tryLock(time, unit)) {
        return false;
      }
      timeoutNanos = deadline - System.nanoTime();
View Full Code Here

    }
    final ReentrantLock lock = this.lock;
    boolean reentrant = lock.isHeldByCurrentThread();
    if (fair || !lock.tryLock()) {
      long deadline = System.nanoTime() + timeoutNanos;
      if (!lock.tryLock(time, unit)) {
        return false;
      }
      timeoutNanos = deadline - System.nanoTime();
    }
View Full Code Here

    final ReentrantLock lock = this.lock;
    long deadline = System.nanoTime() + timeoutNanos;
    boolean signalBeforeWaiting = lock.isHeldByCurrentThread();
    boolean interrupted = Thread.interrupted();
    try {
      if (fair || !lock.tryLock()) {
        boolean locked = false;
        do {
          try {
            locked = lock.tryLock(timeoutNanos, TimeUnit.NANOSECONDS);
            if (!locked) {
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.