Implementing a worker thread