Hi all,
I'm encountering a little problem creating a variable amount of pthreads.
I tried to create this threads in a loop, but that will give me a segmentation fault...
Salem explained here why, but there isn't a solution for me in that topic.
Is there a way to create a number of threads in a for loop?
I was trying it this way, but as said before, that gives a segmentation fault.
Code:void* function(int nmbr){ int i; pthread_t threads[nmbr]; for(i=0;i<nmbr;i++){ pthread_create(&threads[i], NULL,function2,(void *)i); pthread_join(thread[i],NULL); } return NULL; }