Course of Raku / Functional, concurrent, reactive, and web programming / Concurrent programming

Threads

A thread is an independent line of execution that runs alongside the rest of your program. Starting a thread lets a piece of work happen in the background while the main program carries on.

Threads are the lowest-level concurrency tool in Raku. In everyday code you will usually reach for the higher-level promises of the next section, which are built on top of threads but are far easier to combine. Still, it is worth seeing the basic mechanism: how to start a thread and how to wait for it.

Topics in this section

Practice

Complete the quiz that covers the contents of this section.

Exercises

This section contains 3 exercises. Examine all the topics of this section before doing the coding practice.

  1. Run in a thread
  2. Join and wait
  3. Two threads

Course navigation

Solution: None negative   |   Starting a thread