diff --git a/exercises/20_threads/threads2.rs b/exercises/20_threads/threads2.rs index 7020cb9cea..ec6410b57a 100644 --- a/exercises/20_threads/threads2.rs +++ b/exercises/20_threads/threads2.rs @@ -30,5 +30,8 @@ fn main() { } // TODO: Print the value of `JobStatus.jobs_done`. - println!("Jobs done: {}", todo!()); + let jobs_done: u32 = todo!(); + println!("Jobs done: {}", jobs_done); + + assert_eq!(jobs_done, 10, "All 10 threads must update the *shared* status"); } diff --git a/solutions/20_threads/threads2.rs b/solutions/20_threads/threads2.rs index bc268d63f6..f70e21788e 100644 --- a/solutions/20_threads/threads2.rs +++ b/solutions/20_threads/threads2.rs @@ -36,6 +36,12 @@ fn main() { handle.join().unwrap(); } - println!("Jobs done: {}", status.lock().unwrap().jobs_done); - // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + let jobs_done: u32 = status.lock().unwrap().jobs_done; + // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + println!("Jobs done: {}", jobs_done); + + assert_eq!( + jobs_done, 10, + "All 10 threads must update the *shared* status" + ); }