.net - What object should a Monitor wait on? -


While using the monitor. What Object Should Obj (Obj) Obj Use For? In this I am reading on multithreading in .NET, the author starts to use a new object () immediately as a monitor lock. What should you do in this behavior, or it is between two or more threads Is sharing more specific to monitor actual variables?

Yes, I usually lock a new object specifically created . I also have to make sure that it is private and stable and not is a type of object it is also important to realize that you are not actually doing an "object locking" or object, but to lock the token In the form that prevents blocking of code on multiple threads.

This (the current example if you are using C #) is preferred because it can lock any code for example, The possibility of deadlock increases. By creating your own lock object, you can keep yourself in full control.

On locking this tells the logic behind something.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -