]> git.lizzy.rs Git - rust.git/blob - src/test/ui/threads-sendsync/task-comm-12.rs
Merge commit 'e18101137866b79045fee0ef996e696e68c920b4' into clippyup
[rust.git] / src / test / ui / threads-sendsync / task-comm-12.rs
1 // run-pass
2 #![allow(unused_must_use)]
3 #![allow(unused_mut)]
4 // ignore-emscripten no threads support
5
6 use std::thread;
7
8 pub fn main() { test00(); }
9
10 fn start(_task_number: isize) { println!("Started / Finished task."); }
11
12 fn test00() {
13     let i: isize = 0;
14     let mut result = thread::spawn(move|| {
15         start(i)
16     });
17
18     // Sleep long enough for the thread to finish.
19     let mut i = 0_usize;
20     while i < 10000 {
21         thread::yield_now();
22         i += 1;
23     }
24
25     // Try joining threads that have already finished.
26     result.join();
27
28     println!("Joined task.");
29 }