Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pthread_create problem!

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
hi all experts,

i am now having a project which related to some unix programming and a need in use of thread.

i try the simple code in the following under both linux redhat 6.2, and unix solaris 7

however, i can just get the response from linux but not solaris, can anyone help me?

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

void print_message_function(void *ptr);

main()
{
pthread_t thread1, thread2;
char *message1 =
 
/*whole program here*/
#include <stdio.h>
#include <pthread.h>
void print_message_function(void *ptr);
main()
{ pthread_t thread1, thread2;
char *message1 = &quot;hello&quot;;
char *message2 = &quot;world&quot;;
char *message3 = &quot;hey&quot;;
pthread_create( &thread1, NULL, /*(void*)*/&print_message_function, /*(void*)*/ message1);
pthread_create( &thread2, NULL, /*(void*)&*/print_message_function, /*(void*)*/ message2);
exit(0);
}
void print_message_function(void *ptr)
{ char *message;
message = (char *)ptr;
printf(&quot;%s &quot;, message);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top