Given the following class:

class x
{
    Object lockOne = new Object();
    Object lockTwo = new Object();

    List<Something> listOne = new List<Something>();
    List<Something> listTwo = new List<Something>();

    void MethodOne()
    {
        lock(lockOne)
        {
            // some operation on listOne
        }
    }

    void MethodTwo()
    {
        lock(lockTwo)
        {
            // some operation on listTwo
        }
    }
}

Is it correct to use two locking objects assuming that MethodOne() and MethodTwo() can be called from different threads concurrently noting that listOne and listTwo are not related in anyway. The only operations involved in the locks are those specified in the comments above.

Edit
Report