When you say
lock (obj)
...
.NET uses the critical section in obj
to synchronize the following statements.
How is this critical section initialized? (e.g. is it initialized at construction time, or lazily?)
Every object gets a 4 byte "block" of memory allocated to it (the syncblk) that is an index into a SyncTableEntry. When the object is created, the syncblk is assigned 0, which prevents any extra memory allocation (other than this 4 byte number). When a lock is taken, this syncblk is set to the appropriate entry in the table, which may then cause an allocation. In effect, it's a lazy initialization.
When you call lock(object), this is effectively using Monitor.Enter
on the object, which in turn sets the entry appropriately. For details, see this MSDN article on .NET Memory Internals.