Created
November 14, 2013 19:19
-
-
Save pasali/7472682 to your computer and use it in GitHub Desktop.
c thread example
This file contains hidden or 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
#include <pthread.h> | |
#include <stdio.h> | |
void *kare_al(void * p){ | |
int a; | |
a = (int *) p | |
printf(" %d\n", a * a); | |
pthread_exit(NULL); | |
} | |
int main(void){ | |
pthread_t thread1, thread2; | |
pthread_create(&thread1,NULL, kare_al, (void *) 2); | |
pthread_create(&thread2,NULL, kare_al, (void *) 3); | |
pthread_join(thread1,NULL); | |
pthread_join(thread2, NULL); | |
return(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment