1use native_executor::{
2 spawn,
3 timer::{Timer, sleep},
4};
5use std::time::Duration;
6
7fn main() {
8 spawn(async {
9 println!("Starting timers example");
10
11 println!("Waiting for 500ms...");
13 Timer::after(Duration::from_millis(500)).await;
14 println!("500ms elapsed");
15
16 println!("Waiting for 1 second...");
18 Timer::after_secs(1).await;
19 println!("1 second elapsed");
20
21 println!("Sleeping for 2 seconds...");
23 sleep(2).await;
24 println!("2 seconds elapsed");
25
26 println!("Timers example completed");
27 })
28 .detach();
29
30 std::thread::sleep(Duration::from_secs(4));
32}