Code example for BlockingQueue

Methods: isEmpty

0
 
    return true; 
  } 
 
  boolean hasBufferedData() { 
    return !this.bufferQueue.isEmpty();
  } 
 
  /** 
   * @return True if all data has been sent to the client, false if there 
   *    is still some buffered. 
   */ 
  boolean handleWrite() throws IOException { 
    synchronized (this.bufferQueueMutex) {
      ByteBuffer buffer = this.bufferQueue.peek();
      while (buffer != null) {
        this.socketChannel.write(buffer);
        if (buffer.remaining() > 0) {
          return false; // Didn't finish this buffer.  There's more to send. 
        } else { 
          this.bufferQueue.poll();  // Buffer finished.  Remove it.