fix bug in `dispatch_thread`