class FairQueue implements BlockingQueue<E> {

   @Override
   public E take () throws InterruptedException
   {
      E x;
      int c = -1;
      final AtomicInteger count = this.count;
      final ReentrantLock lock = this.lock;
      lock.lockInterruptibly ();
      try
      {
         while (count.get () == 0)
         {
            notEmpty.await ();
         }
         x = getNext (true);
         c = count.getAndDecrement ();
         if (c > 1)
         {
            notEmpty.signal ();
         }
      }
      finally
      {
         lock.unlock ();
      }
      return x;
   }

   public  FairQueue();

}