use mutex & condvar to monitor event queue

rather than nanosleep