Guest User

Untitled

a guest
Jun 17th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. c multithreading process
  2. #include<stdio.h>
  3. #include<pthread.h>
  4.  
  5. void *put (int *arg)
  6. {
  7. int i;
  8. //int * p;
  9. // p=(int*)arg;
  10. for(i=0;i<5;i++)
  11. {
  12. printf("n%d",arg[i]);
  13. }
  14. pthread_exit(NULL);
  15. }
  16.  
  17. int main()
  18. {
  19. int a[5]={10,20,30,40,50};
  20. pthread_t s;
  21. pthread_create(&s,NULL,put,a);
  22. printf("what is thisn");
  23. return 0;
  24. }
  25.  
  26. tm.c:19: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type
  27. /usr/include/pthread.h:227: note: expected ‘void * (*)(void *)’ but argument is of type ‘void * (*)(int *)’
  28.  
  29. #include<stdio.h>
  30. #include<pthread.h>
  31.  
  32.  
  33. void *put (void *arg)
  34. {
  35. int i;
  36. int * p;
  37. p=(int*)arg;
  38. for(i=0;i<5;i++)
  39. {
  40. printf("n%d",p[i]);
  41. }
  42. pthread_exit(NULL);
  43. }
  44.  
  45. int main()
  46. {
  47. int a[5]={10,20,30,40,50};
  48. pthread_t s;
  49. pthread_create(&s,NULL,put,a);
  50. printf("what is thisn");
  51. return 0;
  52. }
  53.  
  54. pthread_join(s, NULL);
Advertisement
Add Comment
Please, Sign In to add comment