How it works...
We will define two variables of the type pthread_t, by the names tid1 and tid2, to store two thread identifiers. These thread identifiers uniquely represent the threads in the system. We will invoke the pthread_create function twice to create two threads and assign their identifiers to the two variables tid1 and tid2, whose addresses are passed to the pthread_create function.
The two threads are created with the default attributes. We will execute the function runThread1 to create the first thread, and then the runThread2 function to create the second thread.
In the runThread1 function, we will display the message Running Thread 1 to indicate that the first thread was created and is running. In addition, we will invoke a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access