最简单的线程
#include<stdio.h>
#include<pthread.h>
void *print_thread_id(void *arg)
{
/* 打印当前线程的线程号*/
printf("Current thread id is %u\n", (unsigned)pthread_self());
}
int main(int argc, char *argv[])
{
pthread_t thread; /*保存线程号*/
/*创建一个线程 */
pthread_create(&thread, NULL, print_thread_id, NULL);
sleep(1); /*休眠1s*/
/*打印进程号 */
printf("Main thread id is %u\n", (unsigned)pthread_self());
return 0;
}