#include <atomic>
#include <cassert>
#include <cstring>
#include <thread>

const char* HELLO = "Hello, World!";

const char* data;
std::atomic<bool> ready;

void producer() {
    data = HELLO;
    ready.store(true, std::memory_order_relaxed);
    // ready.store(true, std::memory_order_release);
}

void consumer() {
    // while (!ready.load(std::memory_order_acquire))
    while (!ready.load(std::memory_order_relaxed))
        ;

    assert(data == HELLO);
}

int main() {
    for (int i = 0; i < 1'000'000; ++i) {
        data = nullptr;
        ready = false;
        std::jthread t1(producer);
        std::jthread t2(consumer);
    }
}
