Class BlockingList<T>


  • public class BlockingList<T>
    extends Object
    A list whose {code compareAndRemove} methods block until the specified item is removed.
    • Constructor Detail

      • BlockingList

        public BlockingList()
    • Method Detail

      • size

        public int size()
        Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
        Returns:
        the number of elements in this list.
      • isEmpty

        public boolean isEmpty()
        Returns true if this list contains no elements.
        Returns:
        true if this list contains no elements.
      • add

        public void add​(T item)
        Adds the passed instance to the list.
        Parameters:
        item - the item to be added to the list.
      • compareAndRemove

        public void compareAndRemove​(T item,
                                     long timeout)
                              throws InterruptedException
        Blocks until the searched item is found and removed from the list.
        Parameters:
        item - The item which is to be removed from the list or null to remove the first item.
        timeout - The time in milliseconds to wait for the item.
        Throws:
        InterruptedException - item was not found in the list in the time allowed time window.
      • compareAndRemove

        public void compareAndRemove​(T item,
                                     Comparator<T> comparator,
                                     long timeout)
                              throws InterruptedException
        Blocks until the searched item is found and removed from the list.
        Parameters:
        item - The item which is to be removed from the list or null to remove the first item.
        comparator - the Comparator used to compare the stored items to the passed one.
        timeout - The time in milliseconds to wait for the item.
        Throws:
        InterruptedException - item was not found in the list in the time allowed time window.