[记] tokio多任务的延时
use tokio::{time};
async fn hh1(){
for _ in 0..10{
time::sleep(std::time::Duration::from_secs(3)).await;
println!("11");
}
}
async fn hh2(){
for _ in 0..20{
time::sleep(std::time::Duration::from_secs(2)).await;
println!("22");
}
}
async fn hh3(){
let d1 = hh1();
let d2 = hh2();
tokio::join!(d1,d2);
}
#[tokio::main]
async fn main() {
// Open a connection to the mini-redis address.
hh3().await;
}
-------------====================分割线====================-------------