Package com.google.common.util.concurrent

Examples of com.google.common.util.concurrent.Monitor


        stringLocks = CacheBuilder.newBuilder().build(new LockCacheLoader());
    }


    public void lock(Object name) {
        Monitor lock;
        synchronized (stringLocks) {
            lock = stringLocks.getUnchecked(name);
        }
        lock.enter();
    }
View Full Code Here


        }
        lock.enter();
    }

    public void unlock(Object name) {
        Monitor lock;
        synchronized (stringLocks) {
            lock = stringLocks.getUnchecked(name);
        }
        lock.leave();
    }
View Full Code Here

        }
        lock.leave();
    }

    public boolean tryLock(Object name) {
        Monitor lock;
        synchronized (stringLocks) {
            lock = stringLocks.getUnchecked(name);
        }
        return lock.tryEnter();
    }
View Full Code Here

     * A simple Guava cache loader implementation for generating object-based locks
     */
    private static class LockCacheLoader extends CacheLoader<Object,Monitor> {
        @Override
        public Monitor load(Object key) throws Exception {
            return new Monitor();
        }
View Full Code Here

TOP

Related Classes of com.google.common.util.concurrent.Monitor

Copyright © 2018 www.massapicom. 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.