
Unsure about posix, but on Windows anyway, 5k threads is a *LOT*! You are probably running out of kernel handles, paged pool, or process space (each thread will take about 2 megs of stack space unless you change linker options). WHAT???? you MUST be mistaken? two MEGABYTES of stack space for a thread??? that seems totally crazy. are you SURE about that??
You should redesign okay well, that may be outside the scope of what is possible at this time. everything *used to* work perfectly fine, when i used pthreads directly, before i switched to using boost::threads.
so i KNOW i'm not asking for something crazy. i should be able to spawn an infinite number of threads during the lifetime of my application, provided they terminate gracefully and clean up and recycle and whatnot, and that i don't spawn ten zillion at one time. yes this is on posix. and i shouldn't be "running out" of anything since the threads die right away, as i said there are really no more than five or ten threads at once. once a thread dies, don't it's resources get "recycled" ??