class FairQueue implements BlockingQueue<E> {

   @Override
   public boolean offer (E e)
   {
      if (e == null)
      {
         throw new NullPointerException ();
      }

      // if storage is full, do not accept new element
      final AtomicInteger count = this.count;

      // Note: convention in all put/take/etc is to preset local var
      // holding count negative to indicate failure unless set.
      int c = -1;
      final ReentrantLock lock = this.lock;
      lock.lock ();
      try
      {
         store (e);
         c = count.getAndIncrement ();

         if (c == 0)
         {
            notEmpty.signal ();
         }
      }
      finally
      {
         lock.unlock ();
      }
      return c >= 0;
   }

   public  FairQueue();

}