A beginner's guide to threading in Rust

Threads allow multiple processes to execute at the same time. The following is a very simple example of a threaded program:

use std::thread;  
fn main()  
{ 
    thread::spawn(||  
    { 
        println!("Hello from a thread in your Rust program"); 
    }); 
} 
Code files can be found in Chapter11/SimpleThreadExample.

When compiled, you may expect the println! to show. However, what you get is this:

Figure 1

Why is the println! not showing?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset