#include <pthread.h>
#include <stdio.h>
#define NUM_THREADS 3
void *PrintHello(void *threadid)
{
long tid;
tid = (long)threadid;
printf("Hello World! It's me , thread #!\n", tid);
pthread_exit(NULL);
}
int main (int argc, char *argv[])
{
pthread_t threads[NUM_THREADS];
int rc;
long t;
for(t=0; t<NUM_THREADS; t++){
printf("In main : creating thread \n", t);
rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
if (rc){
printf("ERROR; retrun code from prh is %d\n", rc);
exit(-1);
}
}
pthread_exit(NULL);
}
결과값 뭐 나오는지 좀 알려줘
댓글 0