com.atlassian.crowd.manager.lock
Class ReentrantLockFactory

java.lang.Object
  extended by com.atlassian.crowd.manager.lock.ReentrantLockFactory
All Implemented Interfaces:
LockFactory

public class ReentrantLockFactory
extends java.lang.Object
implements LockFactory

A lock factory that creates a new instance of ReentrantLock on each call to getLock(String).


Constructor Summary
ReentrantLockFactory()
           
 
Method Summary
 java.util.concurrent.locks.Lock getLock(java.lang.String key)
          Get the lock for the specified key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReentrantLockFactory

public ReentrantLockFactory()
Method Detail

getLock

public java.util.concurrent.locks.Lock getLock(java.lang.String key)
Description copied from interface: LockFactory
Get the lock for the specified key. Getting the lock does not imply that it has been acquired, you still need to acquire and unlock the lock as normal.


     Lock l = lockFactory.getLock("mylock");
     l.lock();
     try {
         // access the resource protected by this lock
     } finally {
         l.unlock();
     }
 

Specified by:
getLock in interface LockFactory
Parameters:
key - the key for this lock
Returns:
the lock for the key


Copyright © 2010 Atlassian. All Rights Reserved.