In the last chapter, we saw how tasks provide a simple way to run multiple streams of compute, even on a single CPU core, when there is I/O involved. However, as the modern CPU has grown to include multiple cores that all operate simultaneously, we need to be able to execute Julia code on them in parallel. The way to do that is typically described as threads or threading, and, in this chapter, we will talk about the facilities Julia provides to run programs on multiple CPU cores simultaneously.
We will begin by noting that Julia's threading features are marked experimental. They are still useful, as you will see in this chapter. However, there is a large internal refactoring that is currently underway. It is expected that these will land in Julia versions 1.3 onward. These changes will make these features more robust, and high-performance, and remove some of their...