On Monday, 5 May 2014 at 17:14:54 UTC, Caslav Sabani wrote:
Hi,
I have just started to learn D. Its a great language. I am
trying to achieve the following but I am not sure is it
possible or should be done at all:
I want to have one array where I will store like 100000
objects.
But I want to use 4 threads where each thread will create 25000
objects and store them in array above mentioned. And all 4
threads should be working in parallel because I have 4 core
processor for example. I do not care in which order objects are
created nor objects should be aware of one another. I just need
them stored in array.
Can threading help in creating many objects at once?
Note that I am beginner at working with threads so any help is
welcome :)
Thanks
I could be wrong here, but I think that the GC actually blocks
when creating objects, and thus multiple threads creating
instances would not provide a significant speedup, possibly even
a slowdown.
You'd want to benchmark this to be certain it helps.