Suppose i have following code
Rectangle rect = new Rectangle();
lock(rect)
{
----
---
---
}
Can the rect object, or its properties be modified in some other thread, while one thread has acquired the lock, and executing in critical section.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If all code that accesses that object first attempts to acquire the same lock, then No.
Without the locking code wrapper, then yes another thread can (and at some point will) write to the
rectwith inconsistent results.