1 // RUN: %clangxx_tsan -O1 %s -o %t && %env_tsan_opts=flush_memory_ms=1 %run %t 2>&1 | FileCheck %s
8 void *Thread(void *stop
) {
9 while (!__atomic_load_n((int *)stop
, __ATOMIC_RELAXED
))
10 close(open("/dev/null", O_RDONLY
));
16 const int kThreads
= 10;
17 pthread_t th
[kThreads
];
18 for (int i
= 0; i
< kThreads
; i
++)
19 pthread_create(&th
[i
], 0, Thread
, &stop
);
21 __atomic_store_n(&stop
, 1, __ATOMIC_RELAXED
);
22 for (int i
= 0; i
< kThreads
; i
++)
23 pthread_join(th
[i
], 0);
24 fprintf(stderr
, "DONE\n");
27 // CHECK-NOT: WARNING: ThreadSanitizer: data race