Roland Schwarz
What do you expect? You cant simply create threads beyond the system limits, which is roughly 2000 on my box. I tried your code with a really short lived thread: by using function void f() {}. This runs "forever". When running in a debugger, then setting a breakpoint, you will see no threads beyond the main running.
On Solaris 10, this example works just fine. I am just trying to say that behaviour on Windows is different from what one would observe on systems with pthreads, since storage for the *thread* can be reclaimed when that thread terminates(pthread_detach). I guess one has to necessarily call thread.join() on Windows.
BTW.: There might be a misconception about the usage of threads. One normally wouldn't like to pay the cost of starting up a thread for short lived tasks.
Of course, thread_pool should be used since thread creation is not all that cheap.
I agree that it would be nice if such a jobs queue would be available in boost. But this doesn't strictly belong to boost::threads. This is kind of an abstraction that should be built on top of boost threads.
Roland
-- regards, Prashant