I was wondering if
synchronize (lock) {
...
}
Where lock is an instance of java.util.concurrent.locks.Lock
, treats lock
like any other object or as the try-finally idiom i.e.
lock.lock();
try {
...
} finally {
lock.unlock();
}
It will treat the lock just like any other object.
Lock documentation:
So basically, it's treated as any other object. And, don't do that.
The lock statement in the C# programming language can be applied to restrict access to a specific part of code to only one thread at a time.