Channels can be used to send data from one thread to another. Below is an example of a simple producer-consumer system, where the main thread produces the values 0, 1, ..., 9, and the spawned thread prints them:
use std::thread;
use std::sync::mpsc::channel;
fn main() {
// Create a channel...