TRT
Sign in

Advanced · Module 11 · Lesson 1 of 6

Launching and Joining Threads

Launch threads from five callable forms and join every thread, so ownership, argument passing and lifetime stay correct from the first program.

Pro — members onlyAbout 9 minutes

By the end you can

  • Launch threads from function pointers, lambdas, functors and member functions
  • Join every thread and explain detached lifetime risks
  • Pass arguments by value or reference wrapper without dangling state

Builds on Project: A Movable Task Type.

01 · A question first

A log server handles five clients at once. Each request runs the same counter loop, started from a different callable form, while main waits at a barrier and releases resources only after the last worker returns. Which call starts a thread, who waits for whom, and what happens when main forgets to wait?

Make a guess before you read on.

02 · The idea

Members only

Unlock the full lesson

This lesson is part of the membership. Join to read it in full, along with every other premium deep dive.

What's inside

  • Why launch has to be explicit
  • The five callable forms
  • Lifetime and order
  • A crew in a vector
  • Errors that end programs
  • Original cast examples
  • Where it is used and what comes next

03 · Practice

Something wrong with this lesson? Report a problem