Possible Duplicate:
How many threads is too many?
I have a large for
loop, in which I want each item to be passed to a function on a thread. I have a thread pool of a certain size, and I want to reuse the threads. What is the most efficient way to do this?
What would be the most efficient size for the thread pool? Or at least what is the best way to figure it out?
pthread_t thread_id[10];
int i;
for(i = 0; i < 10000000; i++) {
pthread_create(thread_id[?], NULL, threadFunc, params[i]);
}