⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hello_multi.c

📁 unix linux 编程实践源代码
💻 C
字号:
/* hello_multi.c - a multi-threaded hello world program */#include  <stdio.h>#include  <pthread.h>#define	NUM	5main(){	pthread_t t1, t2;		/* two threads */	void	*print_msg(void *);	pthread_create(&t1, NULL, print_msg, (void *)"hello");	pthread_create(&t2, NULL, print_msg, (void *)"world\n");	pthread_join(t1, NULL);	pthread_join(t2, NULL);}void *print_msg(void *m){	char *cp = (char *) m;	int i;	for(i=0 ; i<NUM ; i++){		printf("%s", m);		fflush(stdout);		sleep(1);	}	return NULL;}

⌨️ 快捷键说明

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