Created
August 21, 2010 16:47
-
-
Save proudlygeek/542550 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main () { | |
pthread_t thread1, thread2; | |
char message1[] = "I am thread 1"; | |
char message2[] = "I am thread 2"; | |
int numero = 102; | |
int iret1, iret2; | |
pthread_attr_t attr; | |
pthread_attr_init(&attr); | |
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); | |
iret1 = pthread_create (&thread1, &attr, print_function2, (void *) numero); | |
iret2 = pthread_create (&thread2, &attr, print_function, (void *) message2); | |
pthread_attr_destroy(&attr); | |
fprintf (stdout, "Before\n"); | |
fflush (stdout); | |
pthread_join (thread1, NULL); | |
pthread_join (thread2, NULL); | |
fprintf (stdout, "After\n"); | |
fflush (stdout); | |
exit(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment