Question:Consider the following code block:
public class Person
{
    public string GetAge()
    {
        lock (this)
        {
            // Code to get Age of this person object.
        }
    }
}
Which of the following statements is true? 

A lock(this) actually modifies the object passed as a parameter, and in some way makes it read-only or inaccessible. 

B lock(this) can be problematic if the instance can be accessed publicly, because code beyond one's control may lock on the object as well. This could create deadlock situations where two or more threads wait for the release of the same object. 

C lock(this) marks current object as a critical section by obtaining the mutual-exclusion lock for a given object, all private fields of the object become read-only. 

D Implement locking using current application instance or some private variable is absolutely the same and does not produce any synchronization issue, either technique can be used interchangeably. 

+ Answer
+ Report
Total Preview: 851

Copyright © 2024. Powered by Intellect Software Ltd