Moved away from deprecated thread::sleep_ms
Refactored to use thread::sleep and time::Duration and updated link in README.md
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
struct JobStatus {
|
||||
jobs_completed: u32,
|
||||
@@ -16,13 +17,13 @@ fn main() {
|
||||
let status_shared = status.clone();
|
||||
thread::spawn(move || {
|
||||
for _ in 0..10 {
|
||||
thread::sleep_ms(250);
|
||||
thread::sleep(Duration::from_millis(250));
|
||||
status_shared.jobs_completed += 1;
|
||||
}
|
||||
});
|
||||
while status.jobs_completed < 10 {
|
||||
println!("waiting... ");
|
||||
thread::sleep_ms(500);
|
||||
thread::sleep(Duration::from_millis(500));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user