I have an object that I would like to lock.
class TestObj {
Lock lock = new Lock();
public void lockObj {
lock.lock();
}
public void unlockObj {
lock.unlock();
}
// other methods/attributes omitted
}
class Test {
public static void main(String[] args) {
TestObj testObj = new TestObj();
testObj.lockObj();
}
}
Would this lock the TestObj object? So that other objects/threads cannot access this particular TestObj?