Maximum number of threads

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 24 10:43:35 PDT 2015


On Thursday, September 24, 2015 12:38:39 Temtaime via Digitalmars-d-learn wrote:
> Offtop: i think if number of threads > number of real cores, than
> there's something wrong with your design. Maybe fibers suit
> better ?

That depends on what the threads are doing. If they're all CPU-intensive,
then yeah, having more than about the number of real cores isn't going to
work very well, but in many programs, a lot of the threads aren't doing much
(e.g. waiting for something to happen and sitting idly in the meantime). If
anything, I'd guess that it's far more common to have a lot more threads
than cores if a program isn't single-threaded. I'd say that whether the
number of cores matters particularly depends heavily on what your program is
doing. But there are certainly cases where using fibers instead of threads
makes a lot of sense.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list