Created
January 25, 2019 04:55
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <pthread.h> | |
void* f_hilo(void* params){ | |
int *int_params=(int *)params; | |
printf("\n valor %d", *int_params); | |
//pthread_exit(NULL); Se elimina debido a: | |
/* If the | |
start_routine returns, the effect is as if there was an implicit call to pthread_exit() using | |
the return value of start_routine as the exit status.*/ | |
return NULL; | |
} | |
int main(){ | |
pthread_t hilo[10]; | |
int i; | |
int j[10]; | |
for(i=0;i<10;i++){ | |
j[i]=i; | |
pthread_create(&hilo[i], NULL, f_hilo, (void *) &j[i]); | |
//pthread_create(pthread_t *thread, const pthread_attr_t *attr, | |
//void *(*start_routine)(void *), void *arg) | |
} | |
for(i=0;i<10;i++){ | |
pthread_join(hilo[i], NULL); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment