views:

99

answers:

2

I mean for some basic operations, like reads/writes of class attributes. Or, maybe, it introduces some higher level synchronization?

+1  A: 

No it doesn't. You have to synchronize access to objects yourself. Individual reads/writes of 32 bit values on a 32 bit platform are atomic, but that doesn't mean that updates to an object are thread safe.

Since synchronization adds some overhead, adding this for all object would likely be a significant penalty for the overall performance.

Brian Rasmussen
+3  A: 

No, thread-safety is not guaranteed. You can use the lock keyword on reference type instances (simple mutex functionality), for example. The language specification defines which operations are atomic without locks.

The new .NET 4 now includes thread-safe classes like ConcurrentBag that should make it easiert to write code without having to care about locks yourself.

AndiDog