threads ! how?

hi,
how can i write a simple hallo world console program using threads with visual studio.

#include
#include
#include

#define NUM_THREADS 5

void *PrintHello(void *threadid)
{
int tid;
tid = (int)threadid;
printf("Hello World! It's me, thread #%d!
", tid);
pthread_exit(NULL);
}

int main (int argc, char *argv[])
{
pthread_t threads[NUM_THREADS];
int rc, t;
for(t=0; t<NUM_THREADS; t++){
printf("In main: creating thread %d
", t);
rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
if (rc){
printf("ERROR; return code from pthread_create() is %d
", rc);
exit(-1);
}
}
pthread_exit(NULL);
}

this is not working ! pthread header is not known. so how would i do it?
help will be appreciated higly.
thnx
chris
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories