Advertisement
Guest User

method 2 error

a guest
Oct 19th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. void method2()
  2. {
  3. int i,j;
  4. struct place *a;
  5. a=(struct place*)malloc(sizeof(struct place));
  6.  
  7. pthread_t threads[rowSize1*colSize2]; /* descriptors of threads */
  8. for(i = 0; i < rowSize1; i++) /* create threads */
  9. {
  10. for(j=0; j<colSize2; j++)
  11. {
  12. a->r=i;
  13. a->c=j;
  14. if (pthread_create(&threads[i*j], NULL, executeMethod2, (void *)a))
  15. {
  16. printf("Can not create a thread\n");
  17. exit(1);
  18. }
  19.  
  20. }
  21.  
  22. }
  23. for(i = 0; i < rowSize1; i++) /* create threads */
  24. {
  25. for(j=0; j<colSize2; j++)
  26. {
  27. int value; /* value returned by thread */
  28. pthread_join(threads[i*j], (void **)&value);
  29. outputMatrix2[i][j]=value;
  30. printf("%d ",outputMatrix2[i][j]);
  31. }
  32. printf("\n");
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement