Use a queue rather than a thread.