]> git.lizzy.rs Git - rust.git/blob - library/std/tests/thread.rs
Merge commit '40dd3e2b7089b5e96714e064b731f6dbf17c61a9' into sync_cg_clif-2021-05-27
[rust.git] / library / std / tests / thread.rs
1 use std::sync::{Arc, Mutex};
2 use std::thread;
3 use std::time::Duration;
4
5 #[test]
6 #[cfg_attr(target_os = "emscripten", ignore)]
7 fn sleep() {
8     let finished = Arc::new(Mutex::new(false));
9     let t_finished = finished.clone();
10     thread::spawn(move || {
11         thread::sleep(Duration::new(u64::MAX, 0));
12         *t_finished.lock().unwrap() = true;
13     });
14     thread::sleep(Duration::from_millis(100));
15     assert_eq!(*finished.lock().unwrap(), false);
16 }