Code review is a deliberate, detailed inspection of source code to find potential defects. For multithreaded code, examine concurrency risks as well as ordinary bugs; a quick standards check or scan for obvious problems is not enough. section 11.2
A reviewer can be the code’s author or someone else. To review your own work, explain how it operates line by line—as if to another person—and write down the explanation if useful. This can counter the tendency to read what you intended rather than what the code actually does. section 11.2.1 section 11.2
For each line, consider what it does and ask questions such as:
- Which data needs protection from concurrent access, and how is it protected? section 11.2.1
- Where might other threads be, and which mutexes might they or this thread hold? section 11.2.1
- Do operations across threads have ordering requirements, and how are those requirements enforced? section 11.2.1
- Is the data still valid, or could another thread have changed it? section 11.2.1
Review by explaining
Explain a piece of code to a rubber chicken or write detailed notes. At each line, ask what could happen and what data it accesses; try assuming a bug exists and trace how it could arise. section 11.2.1
A careful review can still miss bugs, so follow it with testing to check that the code works. section 11.2









