private void markAsWaitingFor( ForsetiLockManager.Lock lock, Locks.ResourceType type, long resourceId) { clearWaitList(); lock.copyHolderWaitListsInto(waitList); if (lock.anyHolderIsWaitingFor(myId) && lock.holderWaitListSize() >= waitListSize()) { waitList.clear(); throw new DeadlockDetectedException( this + " can't acquire " + lock + " on " + type + "(" + resourceId + "), because holders of that lock " + "are waiting for " + this + ".\n Wait list:" + lock.describeWaitList()); } }
private void clearWaitList() { waitList.clear(); waitList.put(myId); }