Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <pthread.h>
  2. #include <stdio.h>
  3. void *tf(void *arg){
  4. int j;
  5. int *sum;
  6. *sum=0;
  7. for(j=0;j<=9;j++)
  8. *sum+=(void*)&arg;
  9. printf("shows:%dn",*sum);
  10. return NULL;
  11. }
  12. int main(void){
  13. pthread_t tid1;
  14. pthread_t tid2;
  15. void *es;
  16. int value[10]={2,4,6,7,34,66,100,454,600,899};
  17. int value2;
  18.  
  19. value2 =2;
  20. pthread_create(&tid1,NULL,tf,&value);
  21. pthread_create(&tid2,NULL,tf,&value2);
  22. pthread_join(tid1,&es);
  23. pthread_join(tid2,&es);
  24. printf("Threads have finished. n");
  25. return 0;
  26. }
  27. /*I run in ubuntu. It had a warning:assignment makes integer from pointer without a cast[enabled by default]*/
  28. /*please I need someone to help me*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement