I am new to "Threads" programming. I have the following code that is
supposed to create two threads and print seperate messages. The code
compiles OK, but it doesnt print anything to screen when I try to run
it...
Any pointers on what i might be doing wrong...would be much
appreciated....
Regards
Maya
----------Included Code ----------------
#include <pthread.h>
#include <stdio.h>
void print_message_function( void *ptr);
main()
{
pthread_t thread1, thread2;
pthread_attr_t pthread_attr_default;
char *message1 = "Executing FIRST thread";
char *message2 = "Executing SECOND thread";
pthread_create( &thread1, &pthread_attr_default,
(void*)&print_message_function, (void*)message1);
pthread_create(&thread2, &pthread_attr_default,
(void*)&print_message_function, (void*)message2);
exit(0);
}
void print_message_function( void *ptr)
{
char *message;
message = (char *) ptr;
printf("%s", message);
}
---------- End of Included Code----------------------


|