avoid read before write

This commit is contained in:
2025-04-24 22:33:24 +08:00
parent 2f794d04b7
commit 7da2a7bd58

View File

@@ -21,8 +21,8 @@ void reader() {
int main() {
std::thread writer_thread(writer);
std::thread reader_thread(reader);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
std::thread reader_thread(reader);
if (reader_thread.joinable()) {
reader_thread.join();
}