C Program Threads - no Realloc()
void create_thread(){
int i;
for(i =0 ; i < 5;i++){
id[i] = i;
pthread_create(&my_thread[i],NULL,worker,&id[i]);
}
//pthread_exit(NULL);
}
void* worker(void* idp){
int my_id = *((int*)idp);
printf("Hello,I'm thread %d\n",my_id);
sleep(rand()%3);
printf("Hello, I'm thread %d, going away\n",my_id);
pthread_exit(NULL);
return NULL;
}
void create_thread(){
int i;
for(i =0 ; i < 5;i++){
id[i] = i;
pthread_create(&my_thread[i],NULL,worker,&id[i]);
}
//pthread_exit(NULL);
}
void* worker(void* idp){
int my_id = *((int*)idp);
printf("Hello,I'm thread %d\n",my_id);
sleep(rand()%3);
printf("Hello, I'm thread %d, going away\n",my_id);
pthread_exit(NULL);
return NULL;
}