11 void checked_write(int fd, const void *buf, size_t count)
13 ssize_t rc = write(fd, buf, count);
17 void *thread1_func(void *arg)
23 snprintf(buf, sizeof(buf), "thread1: %d %s\n", i, (char *)arg);
24 checked_write(1, buf, strlen(buf));
30 void *thread2_func(void *arg)
35 snprintf(buf, sizeof(buf), "thread2: %d %s\n", i, (char *)arg);
36 checked_write(1, buf, strlen(buf));
42 void test_pthread(void)
46 pthread_create(&tid1, NULL, thread1_func, "hello1");
47 pthread_create(&tid2, NULL, thread2_func, "hello2");
48 pthread_join(tid1, NULL);
49 pthread_join(tid2, NULL);
50 printf("End of pthread test.\n");
53 int main(int argc, char **argv)