Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use futures::future;
- use std::error::Error;
- use tokio::task::JoinHandle;
- #[tokio::main]
- async fn main() -> Result<(), Box<dyn Error>> {
- tokio::spawn(async move {
- let mut handles: Vec<JoinHandle<()>> = Vec::new();
- for a in 1..5 {
- let handle = tokio::spawn(async move {
- println!("Got {}", a);
- });
- handles.push(handle);
- }
- future::join_all(handles).await;
- })
- .await
- .unwrap();
- println!("done!");
- Ok(())
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement