Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Programming Threads > Newbiew Questio...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 1372 of 4146
Post > Topic >>

Newbiew Question : Code Compiles but cant see output ???

by maya_kappur@[EMAIL PROTECTED] (maya) Sep 18, 2004 at 06:19 PM

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




 3 Posts in Topic:
Newbiew Question : Code Compiles but cant see output ???
maya_kappur@[EMAIL PROTEC  2004-09-18 18:19:00 
Re: Newbiew Question : Code Compiles but cant see output ???
Joe Seigh <jseigh_01@[  2004-09-19 02:02:47 
Re: Newbiew Question : Code Compiles but cant see output ???
ptjm@[EMAIL PROTECTED] (  2004-09-19 17:23:39 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 22:28:55 CST 2008.