12 void checked_write(int fd, const void *buf, size_t count)
14 ssize_t rc = write(fd, buf, count);
18 void *thread1_func(void *arg)
24 snprintf(buf, sizeof(buf), "thread1: %d %s\n", i, (char *)arg);
25 checked_write(1, buf, strlen(buf));
31 void *thread2_func(void *arg)
36 snprintf(buf, sizeof(buf), "thread2: %d %s\n", i, (char *)arg);
37 checked_write(1, buf, strlen(buf));
43 void test_pthread(void)
47 pthread_create(&tid1, NULL, thread1_func, "hello1");
48 pthread_create(&tid2, NULL, thread2_func, "hello2");
49 pthread_join(tid1, NULL);
50 pthread_join(tid2, NULL);
51 printf("End of pthread test.\n");
54 int main(int argc, char **argv)