コード例 #1
0
 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;
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 public synchronized boolean isQueued(Thread thread) {
   return wq_.isWaiting(thread);
 }
コード例 #4
0
 public synchronized Collection getQueuedThreads() {
   return wq_.getWaitingThreads();
 }
コード例 #5
0
 public synchronized int getQueueLength() {
   return wq_.getLength();
 }
コード例 #6
0
 public synchronized boolean hasQueuedThreads() {
   return wq_.hasNodes();
 }