com.atlassian.crowd.manager.lock
Interface LockFactory

All Known Implementing Classes:
ReentrantLockFactory

public interface LockFactory

A lock factory returns a lock given a key. Some implementations may return a new instance every time, others may return cached or static instances.


Method Summary
 java.util.concurrent.locks.Lock getLock(java.lang.String key)
          Get the lock for the specified key.
 

Method Detail

getLock

java.util.concurrent.locks.Lock getLock(java.lang.String key)
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();
     }
 

Parameters:
key - the key for this lock
Returns:
the lock for the key


Copyright © 2010 Atlassian. All Rights Reserved.