4. A few ways to use threads

“They were obliged to have him with them,” the Mock Turtle said.      “No wise fish would go anywhere without a porpoise.”“Wouldn’t it, really?” said Alice, in a tone of great surprise.“Of course not,” said the Mock Turtle. “Why, if a fish came to me,      and told me he was going on a journey, I should say ‘With what porpoise?’”

Lewis Carroll, Alice’s Adventures in Wonderland

During the introduction to this book, I mentioned some of the ways you can structure a threaded solution to a problem. There are infinite variations, but the primary models of threaded programming are shown in Table 4.1.

Table 4.1. Thread programming models

All of these models can be combined in arbitrary ways and modified beyond all recognition ...

Get Programming with POSIX ® Threads now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.