im working on an application that handles incoming connections....
each connection is handled with a thread.. the max number of threads is 100
imy code looks like this:
Code:
int threads=0, max_threads=100;
main()
{
while( SOMETHING )
{
if(threads < max_threads)
{
do_stuff();
threads++;
pthread_create(&tid, NULL, &my_thread_function, NULL);
}
}
}
my_thread_function()
{
do_more_stuff();
...
...
...
threads--;
}
im having problems figuring out what am i suppose to do with the thread id var?
an array ?
how can i tell when an tid value is ready for use again ?
thanks in advance for your help....