InternetException

Locking with integer

· 35 words · ~1 min read · in .NET, interview

In short:

it will not work because it requires boxing and boxing will create new object for reference in lock every time code is executed so lock statement will not prevent anything.

Further read:

https://intellitect.com/blog/locking-a-block-of-code-with-an-integer/