Code example for ArrayBlockingQueue

Methods: sizetake

0
   // return value from buffer 
   public int get() throws InterruptedException 
   { 
      int readValue = 0; // initialize value read from buffer
 
      readValue = buffer.take(); // remove value from buffer
      System.out.printf( "%s %2d\t%s%d\n", "Consumer reads ", 
         readValue, "Buffer cells occupied: ", buffer.size() );
 
      return readValue;
   } // end method get 
} // end class BlockingBuffer 
 
 
/************************************************************************** 
 * (C) Copyright 1992-2007 by Deitel & Associates, Inc. and               * 
 * Pearson Education, Inc. All Rights Reserved.                           * 
 *                                                                        * 
 * DISCLAIMER: The authors and publisher of this book have used their     * 
 * best efforts in preparing the book. These efforts include the          * 
 * development, research, and testing of the theories and programs        *