Code example for BlockingQueue

Methods: take

0
    protected boolean isEventAvailable() throws InterruptedException { 
	return !queue.isEmpty();
    } 
 
    protected Event fetchEvent() throws InterruptedException { 
	return queue.take();
    } 
 
    protected Event fetchEventIfPresent() throws InterruptedException { 
	return queue.poll();
    } 
 
    public void notifyEvent(Event ev) {
	queue.add(ev);
    } 
 
    protected void log(String msg) {
	System.out.println(getActorName() + ": " + msg);
    } 
}