Your queue is empty (or rather, missing its first element). The poll method in LinkedList is implemented as such:
public E poll() {
if (size==0)
return null;
return removeFirst();
}
and removeFirst is a method that does throw NoSuchElementException.
You should try and figure out what causes the first element to go missing, since apparently your queue reports a non-zero number of elements. How do you push objects onto the queue?
EDIT: Suggested changes to your code after seeing your edits:
// use a thread-safe queue implementation:
java.util.concurrent.BlockingQueue<ByteBuffer> queue;
// make the constructor private, since it's a singleton you don't want anyone else to be able to instantiate
private Queue() {
queue = new LinkedBlockingQueue<ByteBuffer>();
}
// enQueue and deQueue without a bunch of redundant code:
protected boolean enQueue(ByteBuffer data) {
return queue.offer(data);
}
protected ByteBuffer deQueue() {
return queue.take();
}
// enqueue data like this:
Queue.getInstance().enQueue(tempByteBufRead);
// and dequeue it:
try {
ByteBuffer tempButeBuf = Queue.getInstance().deQueue();
// TODO: do something useful with the buffer
} catch (InterruptedException e) {
}