Performance Guidelines and Pitfalls
Multiple threads can provide significant programming advantages, including simpler programming models and performance improvement. However, there are several performance pitfalls that can have drastic and unexpected negative performance impact, and the impact is not always consistent on different computers, even when they are running the same Windows version. Some simple guidelines, summarizing the experience in this chapter, will help to avoid these pitfalls. Some of these guidelines are adapted from Butenhof's Programming with POSIX Pthreads, as are many of the designing, debugging, and testing hints in the next chapter.Program 9-1.