3 #include <parlib/parlib.h>
4 #include <parlib/vcore.h>
9 pthread_t thandlers[NUM_THREADS];
11 void *handler(void *arg) {
12 int id = pthread_self()->id;
14 struct timespec timeout = {
18 printf("Begin thread: %d\n", id);
19 futex(&var, FUTEX_WAIT, 0, &timeout, NULL, 0);
20 printf("End thread: %d\n", id);
24 int main(int argc, char **argv)
26 for (int i=0; i<NUM_THREADS; i++) {
27 pthread_create(&thandlers[i], NULL, &handler, NULL);
29 for (int i=0; i<NUM_THREADS; i++) {
30 pthread_join(thandlers[i], NULL);