Skip to content

Instantly share code, notes, and snippets.

@RandyMcMillan
Forked from rust-play/playground.rs
Last active July 9, 2025 12:48
Show Gist options
  • Save RandyMcMillan/3f428c15cd0043ca014ec5176ec66f38 to your computer and use it in GitHub Desktop.
Save RandyMcMillan/3f428c15cd0043ca014ec5176ec66f38 to your computer and use it in GitHub Desktop.
tokio_spawn.rs
use tokio::time::{Duration, sleep};
#[tokio::main]
async fn main() {
for _ in 0..1_000_000 {
tokio::spawn(async {
sleep(Duration::from_secs(1)).await;
});
}
println!("Spawned 1M tasks!");
sleep(Duration::from_secs(1)).await;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment