I am building a concurrent application in Java. To avoid exposing my lock object externally, I have a private
final
lock object:
private final Object Lock = new Object();
I use the lock for synchronization between threads:
synchronized (Lock) {
// Do stuff
}
I also use the lock to wait for conditions:
while (conditionIsNotMet) {
Lock.wait();
}
Does using the same object for both concurrency patterns cause any issues? Is there anything I should watch out for when doing this?