示例#1
0
 /**
  * Inserts the specified element into this delay queue.
  *
  * @param e the element to add
  * @return <tt>true</tt>
  * @throws NullPointerException if the specified element is null
  */
 public boolean offer(E e) {
   final ReentrantLock lock = this.lock;
   lock.lock();
   try {
     E first = q.peek();
     q.offer(e);
     if (first == null || e.compareTo(first) < 0) available.signalAll();
     return true;
   } finally {
     lock.unlock();
   }
 }
示例#2
0
 /**
  * Inserts the specified element into this delay queue.
  *
  * @param e the element to add
  * @return <tt>true</tt>
  * @throws NullPointerException if the specified element is null
  */
 public boolean offer(E e) {
   final ReentrantLock lock = this.lock;
   lock.lock();
   try {
     q.offer(e);
     if (q.peek() == e) {
       leader = null;
       available.signal();
     }
     return true;
   } finally {
     lock.unlock();
   }
 }