sthr.cc: single thread
race.cc: concurrent write, no protection
rfix.cc: write protected by std::atomic
lock.cc: write protected by locks
lgua.cc: write protected by lock guards

to compile
c++ -Wall -o sthr sthr.cc -pthread
c++ -Wall -o race race.cc -pthread
c++ -Wall -o rfix rfix.cc -pthread
c++ -Wall -o lock lock.cc -pthread
c++ -Wall -o lgua lgua.cc -pthread

