C
Cool Guy
If I create an object for locking purposes, does it have to be volatile?
e.g.: readonly object fooLock = new Object();
e.g.: readonly object fooLock = new Object();
Lloyd Dupont said:no
volatile keyword is only usefull for variable which could change a few time
in a given SINGLE method call.
Lloyd Dupont said:nice page Jon!
Cool Guy said:Yeah. It's nice and clear.
FWIW, this is the only tutorial that I've ever read on the horrors of
multi-threading. Are there any others that I should read?
If they were specifically about .NET, too, then that'd be great -- but I
assume that Jon's is the only publicly-available one that's specifically
about .NET...
Cool Guy said:I wrote:
[snip]
So what's the rule for determining whether or not some shared data needs to
be volatile?
Jon Skeet said:The exception to this rule is for data which doesn't change, and which
is set up either before any of the reading threads are created, or
there is a memory barrier somewhere in each reading thread before any
reading happens.
Lloyd Dupont said:After much thinking Jon I though that your explanation overstated number of
things.
Number of them I couldn't buy...
So I started hunting for litterature on the topic.
Turn out you that's an awfull topic..... fortunately very simple on x86 (but
remember, .NET runs on IA64...)
http://blogs.msdn.com/brada/archive/2004/05/12/130935.aspx
http://blogs.gotdotnet.com/cbrumme/PermaLink.aspx/480d3a6d-1aa8-4694-96db-c69f01d7ff2b
it's all the more difficult to test whan all you've got is an x86 :/
my comment: while multithreading is simple enough, multi-processor
implementation are broken
(except on x86 )