I need to write code where I'd like one thread to create a lock on a specific system property so that the thread can modify the value, allow an object it uses to access this value but prevent another thread from accessing this system property until the 1st thread returns. Is this possible, and if so, is it correct to do so?
Thanks in advance.
posted 7 years ago
allow an object it uses to access this value
Basically you want to prevent stale data i.e prevent the concurrent access to a system property value for write/read
The best think you can do is to synchronize or acquire the lock on the Object which access the system value