Appearance
Day 18 - tokio
tokio
rust
use tokio::time::{sleep, Duration};
#[tokio::main]
async fn main() {
// 并发任务
let h1 = tokio::spawn(async {
sleep(Duration::from_secs(1)).await;
"task1"
});
let h2 = tokio::spawn(async {
sleep(Duration::from_secs(2)).await;
"task2"
});
let r1 = h1.await.unwrap();
let r2 = h2.await.unwrap();
}📅 学习进度
| Day | 主题 | 状态 |
|---|---|---|
| 01-17 | 基础 | ✅ |
| 18 | tokio | ✅ |
| 19 | 宏 | ⬜ |
