Listing 2: test1.cpp Using the critical section class
#include "critsect.hpp" static CriticalSection::Lock countLock; // Lock to protect count static int count; // count of something void OneMore() { CriticalSection lock(countLock); // Claim critical section ++count; // Operate on count } // OneMore void OneLess() { CriticalSection lock(countLock); // Claim critical section --count; // Operate on count } // OneLess //End of File