how do i?

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


#define NUM_THREADS 5

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

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);

this is not working ! pthread header is not known. so how would i do it?
help will be appreciated higly.
also pls advice on the best book to go for when in it comes to win32 api c/c++.


  • Hmm... does Visual Studio really support pthreads? I'd perhaps expect some other compiler to do so, but not stubborn MS. The only pthread support I know of for Win32 is open source wrapper libraries and such. There is no OS support for them, that's for sure.

    The above link is a discussion on how to port *nix programs to Win32. Scroll down a bit and there is a link to the "threads" topic.
    never lie -- the government doesn't like the competition. (Author unknown)
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!


In this Discussion