Code example for BlockingQueue

Methods: peek, put

0
    */ 
   public String put(String key, String value) {
      this.key = key;
      this.value = value;
      try { 
         trace("::put::send contains: " + send.peek());
         send.put(PUT_SYNC);
      } catch (InterruptedException e) {
         throw new IllegalStateException(e);
      } 
      try { 
         String result = (String) receive.take();
         trace("::put::took out of receive: " + result);
         return result == NULL ? null : result;
      } catch (InterruptedException e) {
         throw new IllegalStateException(e);
      } 
   } 
 
   /** 
    * Only returns when this thread added the given key value.