code: public void newDataReady(DataType data) {
  		ArrayList<Runnable> list;
  		synchronized (this) {
  			if (end) throw new IllegalStateException("method endOfData already called, method newDataReady is not allowed anymore");
  			waitingData.addLast(data);
  			list = listeners;
  			listeners = null;
  		}
  		if (list != null) {
  			for (Runnable listener : list) listener.run();
  		}
  		// notify after listeners
  		synchronized (this) {
  			this.notify();
  		}
  	}
docs: Queue a new data, which may unblock a thread waiting for it.