return buffer.get(0);
    public synchronized ReceivedEvent waitForEvent(long milliseconds) {        if(size()>0) {            return buffer.get(0);        } else {            try {                wait(milliseconds);                if(size()==0) {                    return null;                }                return buffer.get(0);            } catch (InterruptedException e) {                return null;            }        }    }