C语言多线程编程
在一个程序中,这些独立运行的程序片断叫作“线程”(Thread),利用它编程的概念就叫作“多线程处理”。本将介绍c语言如何开启线程。
操作方法
- 01
引入头文件: #include <pthread.h>//开启线程相关头文件#include <stdio.h>
- 02
编写线程函数: void* tprocess(void* args){ //运行程序体 return NULL;}
- 03
调用线程函数: pthread_t t; pthread_create(&t,NULL,tprocess,NULL); pthread_join(t,NULL);
赞 (0)