I have tried example from CLANG TSAN documentation (https://clang.llvm.org/docs/ThreadSanitizer.html):
#include <pthread.h>
int Global;
void *Thread1(void *x) {
Global = 42;
return x;
}
int main() {
pthread_t t;
pthread_create(&t, NULL, Thread1, NULL);
Global = 43;
pthread_join(t, NULL);
return Global;
}
When I compile and run this example, the result is not uniform. I have to run the program several times (multiple program run), to get correct result. Is it normal behavior?