Skip to content

Instantly share code, notes, and snippets.

@proudlygeek
Created August 21, 2010 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save proudlygeek/542550 to your computer and use it in GitHub Desktop.
Save proudlygeek/542550 to your computer and use it in GitHub Desktop.
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