Using event for thread synchronization.