public synchronized boolean recheck(WaitQueue.WaitNode node) { Thread caller = Thread.currentThread(); if (owner_ == null) { owner_ = caller; holds_ = 1; return true; } else if (caller == owner_) { incHolds(); return true; } wq_.insert(node); return false; }
protected synchronized WaitQueue.WaitNode getSignallee(Thread caller) { if (caller != owner_) throw new IllegalMonitorStateException("Not owner"); // assert (holds_ > 0) if (holds_ >= 2) { // current thread will keep the lock --holds_; return null; } // assert (holds_ == 1) WaitQueue.WaitNode w = wq_.extract(); if (w == null) { // if none, clear for new arrivals owner_ = null; holds_ = 0; } return w; }
public synchronized boolean isQueued(Thread thread) { return wq_.isWaiting(thread); }
public synchronized Collection getQueuedThreads() { return wq_.getWaitingThreads(); }
public synchronized int getQueueLength() { return wq_.getLength(); }
public synchronized boolean hasQueuedThreads() { return wq_.hasNodes(); }