event loop based on thread sleep