FileDocCategorySizeDatePackage
PassiveRequestQueue.javaAPI DocExample1043Mon Feb 28 18:01:26 GMT 2000tuning.threads

PassiveRequestQueue

public class PassiveRequestQueue extends Object

Fields Summary
FIFO_Queue
queue
static boolean
shutdown
Constructors Summary
Methods Summary
public synchronized voidacceptRequest(Request r)


      
  
    //Add to the queue, then notify all processors waiting
    //on the releaseRequest() method
    queue.add(r);
    notify();
  
public synchronized voidniceShutdown()

    shutdown = true;
    notifyAll();
  
public synchronized RequestreleaseRequest()

     
  
    for(;;)
    {
      //if the queue is empty, just go back into the wait call
      if (queue.isEmpty())
        try {wait();} catch (InterruptedException e){}

      //We might have been interrupted. If shutdown is true
      //then return a null request to indicate the thread
      //should finish
      if (shutdown)
        return null;

      //Otherwise we need to check again if the queue
      //is empty, just in case.
      if (!queue.isEmpty())
        return (Request) queue.pop();
    }