What are the real advantages that D offers in multithreading?
w0rp via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jan 26 04:58:42 PST 2016
The most important thing D does, which is fundamentally
different, is that variables are thread local by default, and you
must opt-in to variables that are shared across threads.
Immutable data can be shared implicitly, because there are no
writers. This means that if you keep only a small amount of
shared state, it should be easy to track down what could possibly
be affected by multi-threading issues.
I haven't ever used synchronized classes myself, but it's
probably a way of preventing mistakes where you synchronize some
methods, but not others. You can also use synchronized {} blocks
to introduce some recursive locking for a series of statements.
So you could put that inside of a class method.
More information about the Digitalmars-d
mailing list