8. Hints to avoid debugging

“Other maps are such shapes, with their islands and capes!But we’ve got our brave Captain to thank”(So the crew would protest) “that he’s bought us the best—A perfect and absolute blank!”

Lewis Carroll, The Hunting of the Snark

Writing a complicated threaded program is a lot harder than writing a simple synchronous program, but once you learn the rules it is not much harder than writing a complicated synchronous program. Writing a threaded program to perform a complicated asynchronous function will usually be easier than writing the same program using more traditional asynchronous programming techniques.

The complications begin when you need to debug or analyze your threaded program. That’s not so much because using ...

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.