Class Queue


  • public class Queue
    extends Object
    • Constructor Detail

      • Queue

        public Queue()
    • Method Detail

      • put

        public void put​(Object obj)
                 throws InterruptedException
        Put an object on the end of the queue. If the size of the queue is equal to or greater than the current value of maxQueueSize then this method will wait until the size of the queue shrinks to less than maxQueueSize.
        Parameters:
        obj - the object to put at end of queue
        Throws:
        InterruptedException
      • put

        public boolean put​(Object obj,
                           long msecs)
                    throws InterruptedException
        Put an object on the end of the queue. If the size of the queue is equal to or greater than the current value of maxQueueSize then this method will wait until the size of the queue shrinks to less than maxQueueSize.
        Parameters:
        obj - the object to put at end of queue
        msecs - If this method has to wait for the size of the queue to shrink to less than maxQueueSize, it will stop waiting after it has waited this many milliseconds.
        Returns:
        false if this method returns without queuing the given object becuase it had to wait msec milliseconds; otherwise true.
        Throws:
        InterruptedException
      • get

        public Object get​(long msecs)
                   throws InterruptedException
        Get an object from the front of the queue. If queue is empty, waits until it is not empty.
        Parameters:
        msecs - The maximum number of milliseconds that this method should wait before giving up.
        Returns:
        The object at the front of the queue or null if there are no objects in the queue and the method has waited at least the given number of milliseconds for an object to be put in the queue.
        Throws:
        InterruptedException
      • setMaxQueueSize

        public void setMaxQueueSize​(int newValue)
        Set the maximum queue size.