#include #include #include #include void *task1(void *data) { int n = *((int *)data); int ret = 1; while (n) { ret *= n--; } // pthread_exit(&ret); return ret; } int main(int argc, char const *argv[]) { if (argc != 2) { printf("usage: ./%s 数字\n", argv[0]); return 1; } pthread_t tid; int num = atoi(argv[1]); pthread_create(&tid, NULL, task1, (void *)&num); int res; pthread_join(tid, &res); printf("%d\n", res); return 0; }