updated example with separate thread for event/draw loops