1.程序源码
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
void *run(void *arg)
{
char *buf = (char *)arg;
printf("%s\n", buf);
return NULL;
}
int main()
{
pthread_t p = 0;
pthread_create(&p, NULL, run, "hello world");
pthread_join(p, NULL);
return 0;
}
4.编译源码
$ gcc -o run run.c -lpthread
5.运行程序
$ ./run
hello world
网友评论