forked from mirror/async-std
Name threads after what they do
This commit is contained in:
parent
f38923d0cc
commit
a9b970c8ec
1 changed files with 6 additions and 6 deletions
|
@ -44,28 +44,28 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let thread_handle = spawn(move || {
|
let sleepy_thread = spawn(move || {
|
||||||
thread::sleep(time::Duration::from_millis(1000));
|
thread::sleep(time::Duration::from_millis(1000));
|
||||||
String::from("Finished")
|
String::from("Finished")
|
||||||
});
|
});
|
||||||
|
|
||||||
task::block_on(async move {
|
task::block_on(async move {
|
||||||
println!("waiting for thread 1");
|
println!("waiting for sleepy thread");
|
||||||
let thread_result = thread_handle.join().await;
|
let thread_result = sleepy_thread.join().await;
|
||||||
match thread_result {
|
match thread_result {
|
||||||
Ok(s) => println!("Result: {}", s),
|
Ok(s) => println!("Result: {}", s),
|
||||||
Err(e) => println!("Error: {:?}", e),
|
Err(e) => println!("Error: {:?}", e),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let thread_handle = spawn(move || {
|
let panicing_thread = spawn(move || {
|
||||||
panic!("aaah!");
|
panic!("aaah!");
|
||||||
String::from("Finished!")
|
String::from("Finished!")
|
||||||
});
|
});
|
||||||
|
|
||||||
task::block_on(async move {
|
task::block_on(async move {
|
||||||
println!("waiting for thread 2");
|
println!("waiting for panicing thread");
|
||||||
let thread_result = thread_handle.join().await;
|
let thread_result = panicing_thread.join().await;
|
||||||
match thread_result {
|
match thread_result {
|
||||||
Ok(s) => println!("Result: {}", s),
|
Ok(s) => println!("Result: {}", s),
|
||||||
Err(e) => println!("Error: {:?}", e),
|
Err(e) => println!("Error: {:?}", e),
|
||||||
|
|
Loading…
Reference in a new issue