November 2018
Intermediate to advanced
390 pages
10h 8m
English
Concurrency involves using ownership to prevent data races. Parallelism, which refers to the ability for different parts of a program to execute at the same time, is becoming increasingly important as more computers take advantage of multiple processors. Concurrency allows you to write code that’s free of subtle bugs and is easy to refactor without introducing new bugs. Safety is achieved by ensuring that proc owns the captured variables. Threads can communicate with channels as follows:
//Spawn a child thread to be run in parallel spawn(proc() { expensive_computation(); } ); other_expensive_computation();
Read now
Unlock full access