I have implemented locking at the object level for accessing the device:
private static Object device_locker_ = new Object();
public Device getDevice() {
synchronized (device_locker_) {
return device_;
}
}
Can different threads in this case work with the device, calling different methods through getDevice()? Examples:
getDevice().getDeviceInfo()
getDevice().changePIN()
getDevice().doSomething()
All threads work with one instance of the class in which the getDevice () method is defined.
Is it guaranteed in this case that only one thread can work with the device?