Open git001 opened 1 year ago
+1
use std::thread;
use std::time::Duration;
fn main() {
let num_threads = 100000;
let mut handles = Vec::new();
for _ in 0..num_threads {
let handle = thread::spawn(|| {
thread::sleep(Duration::from_secs(10));
});
handles.push(handle);
}
for handle in handles {
handle.join().unwrap();
}
}
use tokio::time;
use tokio::task;
use std::time::Duration;
#[tokio::main]
async fn main() {
let num_tasks = 100000;
let mut tasks = Vec::new();
for _ in 0..num_tasks {
tasks.push(task::spawn(async {
task::sleep(Duration::from_secs(10)).await;
}));
}
for task in tasks {
task.await.unwrap();
}
}
use async_std::task;
use std::time::Duration;
#[async_std::main]
async fn main() {
let num_tasks = 100000;
let mut tasks = Vec::new();
for _ in 0..num_tasks {
tasks.push(task::spawn(async {
task::sleep(Duration::from_secs(10)).await;
}));
}
for task in tasks {
task.await.unwrap();
}
}
Please can you add also the used rust code, thank you