Creating Our Own Fibers 124 fn main() { let mut runtime = Runtime::new(); runtime. init(); runtime. spawn(|| { println!("THREAD 1 STARTING"); let id = 1; for i in 0..10 { println!("thread: {} counter: {}", id, i); yield_thread(); } println!("THREAD 1 FINISHED"); }); runtime. spawn(|| { println!("THREAD 2 STARTING"); let id = 2; for i in 0..15 { println!("thread: {} counter: {}", id, i); yield_thread(); } println!("THREAD 2 FINISHED"); }); runtime. run(); } As you see here, we initialize our runtime and spawn two threads: one that counts to 10 and yields between each count and one that counts to 15. When we cargo run our project, we should get the following output: Finished dev [unoptimized + debuginfo] target(s) in 2. 17s Running `target/debug/green_threads` THREAD 1 STARTING thread: 1 counter: 0 THREAD 2 STARTING thread: 2 counter: 0 thread: 1 counter: 1 thread: 2 counter: 1 thread: 1 counter: 2 thread: 2 counter: 2 thread: 1 counter: 3 thread: 2 counter: 3 thread: 1 counter: 4 thread: 2 counter: 4 thread: 1 counter: 5 thread: 2 counter: 5 thread: 1 counter: 6 thread: 2 counter: 6 thread: 1 counter: 7