1 /* Simple test code with no bug */
3 #include "src/sthread/sthread.h"
8 static void* thread_fun(void* val)
10 sthread_mutex_lock(&mutex);
11 sthread_mutex_unlock(&mutex);
13 fprintf(stderr, "The thread %d is terminating.\n", *(int*)val);
17 int main(int argc, char* argv[])
19 sthread_mutex_init(&mutex, NULL);
24 sthread_create(&thread1, NULL, thread_fun, &id[0]);
25 sthread_create(&thread2, NULL, thread_fun, &id[1]);
26 fprintf(stderr, "All threads are started.\n");
27 sthread_join(thread1, NULL);
28 sthread_join(thread2, NULL);
30 sthread_mutex_destroy(&mutex);
32 fprintf(stderr, "User's main is terminating.\n");