Example usage for java.util.concurrent.locks Lock unlock

List of usage examples for java.util.concurrent.locks Lock unlock

Introduction

In this page you can find the example usage for java.util.concurrent.locks Lock unlock.

Prototype

void unlock();

Source Link

Document

Releases the lock.

Usage

From source file:org.mule.transport.ConcurrentWorkTracker.java

public void removeWork(Runnable work) {
    Lock lock = registryLock.writeLock();

    try {//from  w  ww .j ava2s .c om
        if (logger.isDebugEnabled()) {
            logger.debug("Untracking work: " + work);
        }

        lock.lock();
        works.remove(work);
    } finally {
        lock.unlock();
    }
}

From source file:com.cloudera.oryx.ml.speed.als.ALSSpeedModel.java

public Solver getXTXSolver() {
    RealMatrix XTX;/*from  www .  jav a 2  s.  c om*/
    Lock lock = xLock.readLock();
    lock.lock();
    try {
        XTX = VectorMath.transposeTimesSelf(X.values());
    } finally {
        lock.unlock();
    }
    return new LinearSystemSolver().getSolver(XTX);
}

From source file:com.cloudera.oryx.ml.speed.als.ALSSpeedModel.java

public Solver getYTYSolver() {
    RealMatrix YTY;//from ww  w .j  a  va2s .  co m
    Lock lock = yLock.readLock();
    lock.lock();
    try {
        YTY = VectorMath.transposeTimesSelf(Y.values());
    } finally {
        lock.unlock();
    }
    return new LinearSystemSolver().getSolver(YTY);
}

From source file:no.sesat.search.http.filters.SiteLocatorFilter.java

private static long tryLock(final HttpServletRequest request, final Deque<ServletRequest> deque,
        final Lock lock, long timeLeft) {

    final long start = System.currentTimeMillis();

    try {/*from w  w w  .  j  ava2 s  .  c  o  m*/
        do {
            timeLeft = WAIT_TIME - (System.currentTimeMillis() - start);

            // let's sleep. sleeping too long results in 409 response
            if (0 >= timeLeft || !lock.tryLock(timeLeft, TimeUnit.MILLISECONDS)) {
                // we timed out or got the lock. waiting is over
                break;

            } else if (deque.peek() != request) {
                // we've acquired the lock but we're not at front of deque
                // release the lock and try again
                lock.unlock();
            }
        } while (deque.peek() != request);

    } catch (InterruptedException ie) {
        LOG.error("Failed using user's lock", ie);
    }

    return timeLeft;
}

From source file:com.crossover.trial.weather.metrics.impl.DropwizardMetricsService.java

@Override
public void markRequest(IATA iata, double radius) {
    Assert.isTrue(iata != null, "iata is required");

    Lock read = registryLock.readLock();
    read.lock();//  ww  w.  j  a  v a 2  s .  c  o m
    try {
        registry.meter(iata.getCode()).mark();
        registry.histogram("radius").update(Double.valueOf(radius).intValue() / 10);
    } finally {
        read.unlock();
    }
}

From source file:SoftReferenceCache.java

/**
 * @see java.util.Map#clear()/*from  w w w.  ja  v  a2  s. c o  m*/
 */
public void clear() {
    Lock lock = theLock.writeLock();
    lock.lock();
    try {
        theCache.clear();
    } finally {
        lock.unlock();
    }
}

From source file:edu.internet2.middleware.shibboleth.common.relyingparty.provider.SAMLMDRelyingPartyConfigurationManager.java

/**
 * Gets the metadata provider used to lookup information about entities.
 * /* www . j a v  a2s. c o  m*/
 * @return metadata provider used to lookup information about entities
 */
public MetadataProvider getMetadataProvider() {
    Lock readLock = getReadWriteLock().readLock();
    readLock.lock();
    try {
        return metadataProvider;
    } finally {
        readLock.unlock();
    }
}

From source file:at.newmedialab.ldclient.service.LDCache.java

private void unlockResource(URI resource) {
    Lock lock;
    synchronized (resourceLocks) {
        lock = resourceLocks.remove(resource);
    }//  w w w  .  jav a2s .  c o m
    if (lock != null) {
        lock.unlock();
    }
}

From source file:com.ignorelist.kassandra.steam.scraper.FileCache.java

@Override
public InputStream getIfPresent(Object key) {
    final Lock readLock = stripedLock.get(key).readLock();
    readLock.lock();/*from   www  .  j  av  a  2 s  . c om*/
    try {
        return getIfPresentNonBlocking(key);
    } finally {
        readLock.unlock();
    }
}

From source file:net.sf.fakenames.fddemo.BaseDirLayout.java

public MountInfo.Mount getFs(long dev_t) {
    final Lock lock = mountInfo.getLock();
    lock.lock();/*from   w w  w  .  j  a  v  a2  s. c om*/
    try {
        return mountInfo.mountMap.get(dev_t);
    } finally {
        lock.unlock();
    }
}