所有栏目 | 云社区 美国云服务器[国内云主机商]
你的位置:首页 > 云社区 » 正文

c语言怎么创建线程和使用?

发布时间:2020-04-12 08:40:53

资讯分类:c语言  线程  创建  函数  线程  创建
c语言怎么创建线程和使用?

用 pthread_t创建线程名字。然后pthread_create开辟线程。具体使用。比如有一个函数 void *hello(){printf("create pthread!

");},然后在main函数里面调用,int main(){pthread_t a_thread;pthread_create(&a_thread, NULL, (void *)hello, NULL);}这样就完成了hello()函数的创建和使用,接下来hello函数就会在一个线程中运行

留言与评论(共有 0 条评论)
   
验证码:
Top