12 static void a(void *obj)
14 for (int i = 0; i < N; i++) {
15 x.store(2 * i + 1, std::memory_order_release);
16 y.store(i + 1, std::memory_order_release);
17 z.store(i + 1, std::memory_order_release);
18 x.store(2 * i + 2, std::memory_order_release);
22 static void b(void *obj)
24 printf("x: %d\n", x.load(std::memory_order_acquire));
25 printf("y: %d\n", y.load(std::memory_order_acquire));
26 printf("z: %d\n", z.load(std::memory_order_acquire));
27 printf("x: %d\n", x.load(std::memory_order_acquire));
30 int user_main(int argc, char **argv)
43 printf("Main thread: creating 2 threads\n");
44 thrd_create(&t1, (thrd_start_t)&a, NULL);
45 thrd_create(&t2, (thrd_start_t)&b, NULL);
49 printf("Main thread is finished\n");