[Mono-devel-list] Thread safety of readonly data members?

Michi Henning michi at zeroc.com
Wed Feb 18 20:39:41 EST 2004


Michi Henning wrote:

> And, of course, in C#, there is no volatile keyword, so I guess
> I still have to use a hard lock.

Oops, how embarrassing :-(  Just found this in the doc:

	volatile <declaration>

	The system always reads the current value of a
	volatile object at the point it is requested, even
	if the previous instruction asked for a value from
	the same object. Also, the value of the object is
	written immediately on assignment.

	The volatile modifier is usually used for a field that
	is accessed by multiple threads without using the lock
	statement to serialize access. Using the volatile modifier
	ensures that one thread retrieves the most up-to-date value
	written by another thread.

Well, that definitely answers my question :-)

Sorry for all the unnecessary noise I made!

Cheers,

Michi.





More information about the Mono-devel-list mailing list