www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Error creating thread

reply "exec" <dragon-x gmx.de> writes:
I'm currently fiddling around with some stuff, and I was curious 
how well thousands of threads run simultaneously.
The problem now is, that I'm often running into the following 
exception:
core.thread.ThreadException src\core\thread.d(817): Error 
creating thread

Here's my test program: 
http://pastie.org/private/qqkvbxxkkn7mw9gapqwkg

It only seems to happen with >1000 threads, and I'm seriously 
wondering what's the cause of this.
Jan 13 2012
next sibling parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Fri, Jan 13, 2012 at 08:42:51PM +0100, exec wrote:
 I'm currently fiddling around with some stuff, and I was curious how
 well thousands of threads run simultaneously.
 The problem now is, that I'm often running into the following
 exception:
 core.thread.ThreadException src\core\thread.d(817): Error creating
 thread
 
 Here's my test program:
 http://pastie.org/private/qqkvbxxkkn7mw9gapqwkg
 
 It only seems to happen with >1000 threads, and I'm seriously
 wondering what's the cause of this.
[...] There may be a system-defined limit on the number of threads permitted per process. --T
Jan 13 2012
prev sibling parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On Friday, January 13, 2012 11:52:00 H. S. Teoh wrote:
 On Fri, Jan 13, 2012 at 08:42:51PM +0100, exec wrote:
 I'm currently fiddling around with some stuff, and I was curious how
 well thousands of threads run simultaneously.
 The problem now is, that I'm often running into the following
 exception:
 core.thread.ThreadException src\core\thread.d(817): Error creating
 thread
 
 Here's my test program:
 http://pastie.org/private/qqkvbxxkkn7mw9gapqwkg
 
 It only seems to happen with >1000 threads, and I'm seriously
 wondering what's the cause of this.
[...] There may be a system-defined limit on the number of threads permitted per process.
Yeah. You can have user-defined limits too. IIRC, on Linux, the default thread limit per user is 1024 threads, whereas the system limit is over 60,000. The limits can be tweaked if you need to though. I assume that the situation is similar on Windows, but I don't know. - Jonathan M Davis
Jan 13 2012
parent "exec" <dragon-x gmx.de> writes:
On Friday, 13 January 2012 at 20:02:21 UTC, Jonathan M Davis 
wrote:
 Yeah. You can have user-defined limits too. IIRC, on Linux, the 
 default thread limit per user is 1024 threads, whereas the 
 system limit is over 60,000. The limits can be tweaked if you 
 need to though. I assume that the situation is similar on 
 Windows, but I don't know.

 - Jonathan M Davis
Ah, good to know. Thanks for the info.
Jan 13 2012