This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

pthread


Hello all,

I just subscribed to the list yesterday.  So excuse me if the
following has already been discussed before.

I'm trying to exercise pthread on cyginw.  Following is the code I am
trying to run.  It compiles fine but when it runs I am expecting to
see "Hello World" output but actually see nothing printed.  The same
code was tested under Linux and it ran as expected.  Could anyone tell
me what I am doing wrong here?  Thanks in advance.

-Tak

------------------------------------------------------------------
#include <stdio.h>
#include <pthread.h>

void print_message_function( void *ptr )
{
  char *message;
  message = (char *) ptr;
  fprintf(stderr, "%s ", message);
}

int main(int argc, char **argv)
{
  pthread_t thread1 = 0, thread2 = 0;
  char *message1 = "Hello";
  char *message2 = "World";

  pthread_create(&thread1, NULL,
                 (void*)&print_message_function, (void*) message1);
  pthread_create(&thread2, NULL, 
                 (void*)&print_message_function, (void*) message2);
  return 0;
}

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]