Skip to content

Instantly share code, notes, and snippets.

@todmephis
Created January 25, 2019 04:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save todmephis/3f2bc5acec92754763870057551e5332 to your computer and use it in GitHub Desktop.
#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