Beispiel #1
0
 // Notifies all the threads waiting on the object.
 protected final void notifyAll(Component host_, Object o_) {
   if (o_ == null) return;
   String old_ = state;
   setState(State_NOTIFYING);
   // sleepOn = o_;
   LockPack p_ = lookforLock(host_, o_);
   synchronized (o_) {
     // setState(State_NOTIFYING2);
     // sleepOn = null;
     if (p_.waitCount == 0) return;
     // runtime._notifyMany(o_, p_.waitCount, this);
     synchronized (aruntime) {
       if (aruntime.getWorkforce(p_.waitCount)) {
         o_.notifyAll(); // dont know who's going to wake up
         aruntime.nthreadsWaiting -= p_.waitCount;
       } else {
         int remainingWorkforce_ = aruntime.getRemainingWorkforce();
         // notify "remainingWorkforce_" threads
         for (int i = 0; i < remainingWorkforce_; i++) o_.notify();
         aruntime.nthreadsWaiting -= remainingWorkforce_;
         for (int i = p_.waitCount - remainingWorkforce_; i > 0; i--)
           aruntime.newTask(Task.createNotify(o_), this);
       }
     }
     p_.waitCount = 0;
   }
   setState(old_);
 }