-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThreads.rs
More file actions
35 lines (31 loc) · 1.01 KB
/
Copy pathThreads.rs
File metadata and controls
35 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
Threading
*/
use std::thread;
use thread::JoinHandle;
use std::time::Duration;
fn main(){
println!("This is print1");
println!("This is print2");
println!("This is print3");
println!("This is print4");
let t:JoinHandle<()> = thread::spawn(|| {
println!("This is print1 in thread");
println!("This is print2 in thread");
println!("This is print3 in thread");
println!("This is print4 in thread");
println!("This is print5 in thread");
thread::sleep(Duration::from_millis(1));
println!("This is print6 in thread");
println!("This is print7 in thread");
println!("This is print8 in thread");
println!("This is print9 in thread");
println!("This is print10 in thread");
});
thread::sleep(Duration::from_millis(1));
println!("This is print1 out of thread");
println!("This is print2 out of thread");
println!("This is print3 out of thread");
println!("This is print4 out of thread");
t.join();
}