Package java.util.concurrent.locks

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


    long remainingNanos;
    if (!fair && lock.tryLock()) {
      remainingNanos = unit.toNanos(time);
    } else {
      long startNanos = System.nanoTime();
      if (!lock.tryLock(time, unit)) {
        return false;
      }
      remainingNanos = unit.toNanos(time) - (System.nanoTime() - startNanos);
    }
    boolean satisfied = false;
View Full Code Here


    final ReentrantLock lock = this.lock;
    boolean reentrant = lock.isHeldByCurrentThread();
    boolean interruptIgnored = false;
    try {
      long remainingNanos;
      if (!fair && lock.tryLock()) {
        remainingNanos = unit.toNanos(time);
      } else {
        long startNanos = System.nanoTime();
        long timeoutNanos = unit.toNanos(time);
        remainingNanos = timeoutNanos;
View Full Code Here

        long startNanos = System.nanoTime();
        long timeoutNanos = unit.toNanos(time);
        remainingNanos = timeoutNanos;
        while (true) {
          try {
            if (lock.tryLock(remainingNanos, TimeUnit.NANOSECONDS)) {
              break;
            } else {
              return false;
            }
          } catch (InterruptedException ignored) {
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 {
      satisfied = guard.isSatisfied();
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 {
      satisfied = guard.isSatisfied();
View Full Code Here

            @Override
            public IterableXMLEventReader transmit(Request request) {
                //do not allow transmit until we confirm everything got saved
               // lock.lock();
                if (lock.tryLock()) {
                    try {
                        return super.transmit(request);
                    } 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

    public void deploy(Application app)
    {
        final ReentrantLock lock = deploymentService.getLock();
        try
        {
            if (!lock.tryLock(0, TimeUnit.SECONDS))
            {
                return;
            }
            app.install();
            app.init();
View Full Code Here

    public void undeploy(Application app)
    {
        final ReentrantLock lock = deploymentService.getLock();
        try
        {
            if (!lock.tryLock(0, TimeUnit.SECONDS))
            {
                return;
            }

            app.stop();
View Full Code Here

    public Application installFromAppDir(String packedMuleAppFileName) throws IOException
    {
        final ReentrantLock lock = deploymentService.getLock();
        try
        {
            if (!lock.tryLock(0, TimeUnit.SECONDS))
            {
                throw new IOException("Another deployment operation is in progress");
            }

            final File appsDir = MuleContainerBootstrapUtils.getMuleAppsDir();
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.