Guest User

Untitled

a guest
Mar 24th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <pthread.h>
  3.  
  4. void* fun1(void *pv)
  5. {
  6.     const char *str = pv;
  7.     printf("%s\n", str);
  8.     return NULL;
  9. }
  10.  
  11. void* (*funptr)(void *);
  12.  
  13. int main()
  14. {
  15.     char msg1[10]="Hi";
  16.     char msg2[10]="Hello";
  17.     pthread_t pid1, pid2;
  18.    
  19.     funptr = fun1;
  20.    
  21.     pthread_create(&pid1, NULL, funptr, msg1);
  22.     pthread_create(&pid2, NULL, funptr, msg2);
  23.    
  24.     pthread_join(pid1,NULL);
  25.     pthread_join(pid2,NULL);
  26.    
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment