aboutsummaryrefslogtreecommitdiffstats
path: root/meson/test cases/wasm/2 threads/threads.c
blob: e79bff1705bc5c116b0789b8858723c482b8fb1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>

void inthread(void * args) {
    sleep(1);
    printf("In thread\n");
}

int main() {
#ifdef __EMSCRIPTEN_PTHREADS__
    pthread_t thread_id;
    printf("Before Thread\n"); 
    pthread_create(&thread_id, NULL, (void *)*inthread, NULL); 
    pthread_join(thread_id, NULL); 
    printf("After Thread\n");
    return 0;
#else
# error "threads not enabled\n"
#endif
}