Howdy, Stranger!

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


how do i?

dinga94dinga94 Member Posts: 18
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++.


  • LundinLundin Member Posts: 3,711
    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.
  • stoberstober Member Posts: 9,765 ✭✭✭

    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.