How can we synchronize accessing a common resource using synchronization in Java when my java application is deployed on multiple instances behind a load balancer ?
Because, as far as I know, synchronization works only under one JVM. But when we deploy the same Java application on multiple instances to handle the load, then how can we provide a synchronization mechanism?
For example:- There is a HDFS file to which the java application either appends/edits the contents of that HDFS file. When I deploy my java application on multiple instances, then how can I make sure that only one request from Java application accesses that HDFS file ?