PDA

View Full Version : pthread_create() spawns multiple threads



DBQ
April 7th, 2010, 08:08 PM
Hi everybody.

I have a problem. In the for loop I create n threads. However, when I run the program through GDB I see that each single pthread_create() call spawns multiple threads. Why is this happening?

tookyourtime
April 7th, 2010, 08:29 PM
Well does the function that you start in the new thread end up creating more threads itself?

And what is the code for your loop?

DBQ
April 7th, 2010, 09:14 PM
My code is something like this:



void* thread_func()
{
sleep(100);
pthread_exit();
}

for(i=0; i < 10; ++i)
{
pthread_create();
}

tookyourtime
April 7th, 2010, 09:45 PM
Sorry I still think more information is needed to be able to find the problem.

Full source code, how many more threads are created than expected?
And what is the aim of the program?