C++ if one thread writes toggles a bool once done, is it safe to read that bool in a loop in a single other thread?
问题 I am building a very simple program as an exercise. The idea is to compute the total size of a directory by recursively iterating over all its contents, and summing the sizes of all files contained in the directory (and its subdirectories). To show to a user that the program is still working, this computation is performed on another thread, while the main thread prints a dot . once every second. Now the main thread of course needs to know when it should stop printing dots and can look up a