Programming with Hyper-Threading Technology: How to Write Multithreaded Software for Intel IA-32 Processors

Now that you have learned how to launch threads, you need to understand how to coordinate activity among them. It is important to remember that once you step into the world of parallel programming, the relationships and interactions among threads are a constant programming and design issue. Recall that your main program is itself a thread and so anytime you start up threads, you are involved in their management. This management usually addresses two of the challenges touched on in the previous chapter: coordinating the timing between thread executions and avoiding conflicts when two threads access the same data or code.
The world of parallel programming is filled with devices that help get around these challenges, and this chapter examines the most important of these. Let's start with a simple case.