#inluce<stdio.h> |
#include<pthread.h> |
#define NUM 5 |
int main() |
{ |
pthread_t t1,t2; |
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); |
return 0; |
} |
void *print_msg( void *m) |
{ |
char *cp=( char *)m; |
int i=0; |
for (i=-0;i<NUM;i++){ |
printf ( "%s" ,m); |
fflush (stdout); |
sleep(1); |
} |
return NULL: |
} |
初级程序员
by: 赶蚊子 发表于:2017-06-20 11:01:35 顶(0) | 踩(0) 回复
good
回复评论