List of utility methods to do Thread Lock
Class> | loadClassWithRegisteredClassLoaders(String className) Loads a class with the reigistered class loaders. if (className == null) { throw new ClassNotFoundException("Class name is null!"); LOCK.readLock().lock(); try { if (CLASSLOADER_MAP == null) { throw new ClassNotFoundException(); for (Map<String, ClassLoader> clm : CLASSLOADER_MAP.values()) { for (Map.Entry<String, ClassLoader> cle : clm.entrySet()) { if (cle.getKey().equals(className)) { return loadClass(className, cle.getValue()); throw new ClassNotFoundException(); } finally { LOCK.readLock().unlock(); |
void | lock(Lock lock) Simply locks passed Lock object lock.lock(); |
void | lock(Lock lock) lock if (lock != null) {
lock.lock();
|
Stack | lockAll(List lock All Stack<Lock> lockedLocks = new Stack<Lock>(); for (Lock lock : locks) { if (lock.tryLock()) { lockedLocks.push(lock); } else { break; return lockedLocks; |
void | lockedSleep(Lock l, long time) Releases l before sleeping and then acquires l after sleeping.
l.unlock(); try { Thread.sleep(time); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } finally { l.lock(); |
LinkedBlockingDeque | newLinkedBlockingDeque(Collection extends T> collection) new Linked Blocking Deque return collection != null ? new LinkedBlockingDeque<T>(collection) : new LinkedBlockingDeque<T>(); |
void | release() release _lock.release(); |
void | releaseLock(final Lock lock) release Lock lock.unlock(); |
void | releaseReadLock(final ReadWriteLock lock) release Read Lock releaseLock(lock.readLock()); |
void | runSync(final Lock lock, final Runnable task) Run task synchronously on current thread using provided lock for synchronization. try { lock.lock(); task.run(); } finally { lock.unlock(); |