Will lock() statement block all threads in the process/appdomain?

后端 未结 6 1272
执念已碎
执念已碎 2020-12-17 17:47

Maybe the question sounds silly, but I don\'t understand \'something about threads and locking and I would like to get a confirmation (here\'s why I ask).

So, if I h

6条回答
  •  忘掉有多难
    2020-12-17 18:34

    The C# lock statement locks on a particular instance of an object (the object you created with new object()). Objects are (in most cases) not shared across AppDomains, thus if you are having 10 servers, 10 threads can run concurrently access your database with that piece of code.

提交回复
热议问题