Fixed the deadlock between main thread and reader thread