27 wiersze
627 B
Rust
27 wiersze
627 B
Rust
![]() |
//-- #########################
|
||
|
//-- Task: Spawning multiple threads in rust
|
||
|
//-- Author: Vigneshwer.D
|
||
|
//-- Version: 1.0.0
|
||
|
//-- Date: 19 March 17
|
||
|
//-- #########################
|
||
|
|
||
|
use std::thread;
|
||
|
|
||
|
fn main() {
|
||
|
thread::spawn(move || {
|
||
|
println!("Hello from spawned thread");
|
||
|
});
|
||
|
|
||
|
let join_handle = thread::spawn(move || {
|
||
|
println!("Hello from second spawned thread");
|
||
|
17
|
||
|
});
|
||
|
|
||
|
println!("Hello from the main thread");
|
||
|
|
||
|
match join_handle.join() {
|
||
|
Ok(x) => println!("Second spawned thread returned {}", x),
|
||
|
Err(_) => println!("Second spawned thread panicked")
|
||
|
}
|
||
|
}
|