From f3f624c44c43c1d8318d70a667ce8eedfa143036 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 4 Oct 2023 01:34:24 -0700 Subject: [PATCH] gpt: unconditionally spawn new worker --- src/worker.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/worker.rs b/src/worker.rs index dfdf8b0..4f978b6 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -53,4 +53,12 @@ fn main() { // Sleep to allow worker thread to finish processing thread::sleep(std::time::Duration::from_secs(2)); -} \ No newline at end of file + + // Send another task, which will spawn a new worker + let new_worker = Worker::new(2, Arc::clone(&receiver)); + new_worker.start(); + sender.send("New Task".to_string()).unwrap(); + + // Sleep to allow the new worker thread to process the task + thread::sleep(std::time::Duration::from_secs(2)); +}