Chapter 11: Using Threads in Your Programs
In this chapter, we will learn what threads are and how to use them in Linux. We will write several programs using POSIX threads, otherwise known as pthreads. We will also learn what race conditions are and how to prevent them by using mutexes. Then, we'll learn how to make a mutex program more efficient. Lastly, we'll learn what condition variables are.
Knowing how to write threaded programs will make them faster and more efficient.
In this chapter, we will cover the following recipes:
- Writing your first threaded program
- Reading return values from threads
- Causing a race condition
- Avoiding race conditions with mutexes
- Making the mutex program more efficient
- Using condition variables
Let's get started!