And what happens when I try to spawn too many?
I’m getting the following error when I spawn more than about 900 threads:
terminate called after throwing an instance of 'dining 1
boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::thread_resource_error>
>dining 3
'
dining 2
what(): dining 4
boost::thread_resource_errordining 3
Is this the expected error resulting from attempting to spawn too many threads?
Remember that each thread needs to reserve stack space. That is why there is a limit on the number of threads you can spawn. It looks like you are either hitting this limit or boost is stopping you from hitting this limit.
Here is a link to the most recent boost documentation that documents the behavior you are seeing (the exception thrown): boost thread docs (search for boost::thread_resource_error on that page)