Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <pthread.h>
- void *threadMessage( void *ptr );
- main()
- {
- pthread_t thread1, thread2;
- char *message1 = "Thread 1 says hi !";
- char *message2 = "Thread 2 says hi !";
- int retStat1, retStat2;
- retStat1 = pthread_create( &thread1, NULL, threadMessage, (void *) message1);
- retStat2 = pthread_create( &thread2, NULL, threadMessage, (void *) message2);
- pthread_join( thread1, NULL);
- pthread_join( thread2, NULL);
- printf("Thread 1 returns: %d\n",retStat1);
- printf("Thread 2 returns: %d\n",retStat2);
- exit(0);
- }
- void *threadMessage( void *ptr )
- {
- char *message = (char *) ptr;
- printf("%s \n", message);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement