games.strategy.thread
Class LockUtil
java.lang.Object
games.strategy.thread.LockUtil
public class LockUtil
- extends java.lang.Object
Utility class for ensuring that locks are acquired in a consistent order.
Simply use this class and call acquireLock(aLock) releaseLock(aLock) instead
of lock.lock(), lock.release(). If locks are acquired in an inconsistent order,
an error message will be printed.
This class is not terribly good for multithreading as it
locks globally on all calls, but that is ok, as this code
is meant more for when you are considering your ambitious
multi-threaded code a mistake, and you are trying to limit the
damage.
- Author:
- sgb
|
Method Summary |
static void |
acquireLock(java.util.concurrent.locks.Lock aLock)
|
static boolean |
isLockHeld(java.util.concurrent.locks.Lock aLock)
|
static void |
releaseLock(java.util.concurrent.locks.Lock aLock)
|
static void |
setErrorReporter(games.strategy.thread.ErrorReporter reporter)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LockUtil
public LockUtil()
acquireLock
public static void acquireLock(java.util.concurrent.locks.Lock aLock)
releaseLock
public static void releaseLock(java.util.concurrent.locks.Lock aLock)
isLockHeld
public static boolean isLockHeld(java.util.concurrent.locks.Lock aLock)
setErrorReporter
public static void setErrorReporter(games.strategy.thread.ErrorReporter reporter)