The problem: I'm preparing single-instance application to become multi-instance. There are a lot of Lock
usages (from java.util.concurrent.locks
package) to synchronize access to some resources (external files on other server). Now for synchronizing ReentrantLock
implementation of Lock
is used.
To share locks between instances I want to use PostgreSQL database table which is already connected via JDBC. Since all consumers uses only Lock
interface (not uses ReentrantLock
class directly) I want to replace Lock
implementation with Lock
based on database table.
What is the correct way to implement Lock
based on database table? Or maybe any standard java.util.concurrent.locks.Lock
implementation based on JDBC exists?
UPDATE:
I'm not looking for table locking mechanism (like in Table lock in PostgreSQL question), I need Lock
implementation to use it in-code, not in SQL.