title: How to avoid concurrency running in two instances when using schedulers or public synchronized void run()
body: <p>I am using glassfish 3.1.2 build 5. I have two servers and each have 1 cluster. Each cluster have 2 instances. In my J2EE application i have schedulers(Cron Quartx schedulers) which will run every day at night 12 and also simply running below code at 30000(milli secs) interval </p>
  
  <pre><code>public synchronized void run() {
   /** Some set of functions **/
  /** Calling procedure **/
  if count &gt;0{
  /** forming xml and updating web service**/
  }else {
  Thread.sleep(Integer.parseInt(30000));
  }
  </code></pre>
  
  <p>My problem is when i deploy my application as a stand alone instance its running fine . When i deploy the same in above cluster and load balancing structure either i am facing null pointer exception or my applications got processed for 4 times. But it should happen only one for each application ? How to avoid this concurrency ?</p>