use async_std::task;
use std::time::Duration;
use chrono::Local;
use std::rc::Rc;
use std::cell::RefCell;
async fn hello_world1(val: Rc<RefCell<i32>>) {
task::sleep(Duration::from_secs(2)).await;
*val.borrow_mut() += 10;
println!("hello world1!, {}", Local::now());
}
async fn hello_world2() {
task::sleep(Duration::from_secs(3)).await;
println!("hello world2!, {}", Local::now());
}
async fn say_hello() {
let val = Rc::new(RefCell::new(10));
task::spawn_local(hello_world1(Rc::clone(&val)));
hello_world2().await;
println!("{}", *val.borrow())
}
fn main() {
println!("start time = {}", Local::now());
task::block_on(say_hello());
}