a better way to stop worker thread