pthread hangs after spawning x pthreads
I have an application that calls a function from main, and in that function it spawns a pthread using pthread_create (Thread 1). Then Thread 1 loops forever spawning a pthread (Thread 2), wainting for Thread 2 to return, and then respawns Thread 2. For some reason after it spawns Thread 2 76 times Thread 1 just hangs.
Is this not a valid thing to do?
Is there something else I need to do to clean up Thread 2 when it returns?
I have tried exiting Thread 2 using pthread_exit, but that didn't make any difference. Also it doesn't seem like a memory leak, since in another terminal I can start my application again which will hang at the same number of thread spawn loops.
|