Advertisement
Guest User

Ahora me falla

a guest
Nov 28th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. #include <pthread.h>
  2. #include <stdio.h>
  3.  
  4. #define MAX_THREADS 3
  5.  
  6. void * ex(void * data) {
  7. pthread_exit(NULL);
  8. return NULL;
  9. }
  10.  
  11. int main(int argc, char * argv[]){
  12.  
  13. int rc;
  14. pthread_t thread_id[MAX_THREADS];
  15. int i;
  16.  
  17. for(i = 0; i < MAX_THREADS; i++){
  18.  
  19. rc = pthread_create(&thread_id[i], NULL, ex, (void*)i);
  20. if(rc){
  21. printf("\n ERROR: El codi retornat és %d \n", rc);
  22. exit(-1);
  23. }
  24.  
  25. printf("\n pthread_self (%d). Sóc el thread %d creat a la iteracció %d ...\n", pthread_self(), thread_id[i], i);
  26. sleep(1);
  27. }
  28.  
  29. pthread_exit(NULL);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement