The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

DamonCarr (7) [Avatar] Offline

I am totally confused by what you have written in relation to the volatile keyword.

On page 138 you say:

"All fields encosed in a synchronization block and accessed by multiple threads should be volatile"

Then on page 139 (the next page!) you say:

"If a synchronization lock is used, thre is no reason to use volitile."

and then you say:


* A variable is accessed from Multiple threads
* No Synchronization mechanisms are being used (DAMON: Isn't that basically suicide?)
* Only one thread will update the value

You also (in the text) make this seem like an optimization for the ReaderWriterLock only as you say:

"When more then one thread is reading.. And one is Writing" is a 'safely used' instance for volatile. This is terribly incoherent and I am hoping for a second edition that addresses .NET 1.1 SP1 and .NET 2.0. Is that planned?

I need every ms performance I can get in my apps I build that are multithreaded transactional servers for the worlds largest financial services companies.. Can you help me here so I do not need to analyze the MSIL?

Kind regards,
Damon Carr, CEO and Chief Technologist