thread.c

来自「linux下线程编程序事例,已经验证过了,很好用」· C语言 代码 · 共 31 行

C
31
字号
#include <pthread.h>#include <stdio.h>//#define NULL 0void *threadA(void *arc){	while(1)	{        	printf("hello threadA\n");		sleep(2);         }}void *threadB(void *arc){	while(1)	{		printf("hello threadB\n"); 		sleep(2222222222222222222222main(){	pthread_t threadidA, threadidB;          pthread_create(&threadidA, NULL, &threadA, NULL);	pthread_create(&threadidB, NULL, &threadB, NULL);       // pthread_create(NULL, NULL, NULL, NULL);	while(1)	{        	sleep(1);		printf("main test\n");        }	return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?