I wanna check a head element before taking but raises
java.lang.NullPointerException when peeking,
using java BlockingQueue
BlockingQueue sharedQueue = new LinkedBlockingQueue() this is my code, any ideas?
while(true){ try { if(!sharedQueue.isEmpty()){ char ch = (char)sharedQueue.peek(); if(Character.isDigit(ch)){ digitTextField.setText(digitTextField.getText()+sharedQueue.take()); } } } catch (InterruptedException ex) { Logger.getLogger(Form.class.getName()).log(Level.SEVERE, null, ex); } }