Complete these tasks to reinforce what you learned in this module.
In main, spawn a thread that prints "thread: 1". In main, print "main: 0". Join the thread before main exits. Order of prints may vary; both lines must appear.
std::thread::spawn with a closure; the closure prints one line. Main prints the other, then waits for the thread using the handle returned by spawn.// Task 1: Spawn thread. See tasks/TASKS.md.
fn main() {
todo!("Spawn thread that prints thread: 1, main prints main: 0, join");
}
Create an mpsc::channel(). Spawn a thread that sends the number 100 over the channel. In main, receive the value and print "received: 100".
mpsc::channel(); you get a sender and receiver. The spawned thread must own the sender (use move); main receives on the receiver. Both are in std::sync::mpsc.// Task 2: Channel. See tasks/TASKS.md.
fn main() {
todo!("Channel, thread sends 100, main receives and prints");
}