Package com.im.commons.progress
Interface DFLock
-
public interface DFLockA lock that can be used to restrict access to a DIF object. The lock should be released when you finish all your changes.Note 1: Do not keep the lock for long time, release it when possible. During the time you have a DIF object locked, no other action can do anything with this and all actions are disabled.
Node 2: The recommended code for lock obtaining and releasing is:
DFLock lock = null; try { lock = someObject.getLockable().obtainLock("doing some change"); someObject.doTheOperationWithLock(...); } finally { if (lock != null) { lock.release(); } }This type of code is pretty safe and always release the lock even if the operation fails.- Author:
- Tim Dudgeon
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.StringgetReason()booleanisValid()When lock is released it become invalid and cannot be used more.voidrelease()Releases the lock.
-
-
-
Method Detail
-
isValid
boolean isValid()
When lock is released it become invalid and cannot be used more.- Returns:
- whether this lock was already
released
-
release
void release()
Releases the lock. Further releases will throwIllegalStateException.
-
getReason
java.lang.String getReason()
- Returns:
- the reason of locking (usually the action human readable name)
-
-