/*
 * https://undo.io/resources/gdb-watchpoint/using-helgrind-to-debug-data-races
 *
 * valgrind --tool=helgrind ./a.out
 */

#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>

int Global;

void*
Thread1(void *x) {
	Global = 42;
	return x;
}

int
main(void) {
	pthread_t t;
	pthread_create(&t, NULL, Thread1, NULL);
	for(int i = 0; i < 10000000 ; i++)
		;
	Global = 43;
	pthread_join(t, NULL);
	return Global == 42 ? EXIT_SUCCESS : EXIT_FAILURE;
}
