title: How to solve this Timer issue in java?
body: <p>Im developing the java Email application with Timer, I have a two arraylists named ActiveProcesses,InActiveProcesses. If I start the Timer it will send the Email with InActiveProcesses list values for every seconds. But the problem is the timer is sent the Email if the InActiveProcesses list values is same.For Example the InActiveProcess list contains the value <code>abcd</code>, it will send Email every seconds with same List values. I want to send the Email only the InActiveProcesses list contains different values. The Timer will check the values every seconds if the values are different it will send the Email. How to handle this problem using java. Thanks in advance. Here is the code, </p>
  
  <pre><code>for (int i = 0; i &lt; InActiveProcess.size(); i++)
  {
      if (!ActiveProcess.contains(InActiveProcess.get(i)))
      {
          list3.add(InActiveProcess.get(i));
      }
  }
  for (int i = 0; i &lt; ActiveProcess.size(); i++)
  {
      if (!InActiveProcess.contains(ActiveProcess.get(i)))
      {
          list3.add(ActiveProcess.get(i));
      }
  }
  log.info("Processes which are Not Running: " + list3);
  
  StringBuilder sb = new StringBuilder();
  
  for (int k = 0; k &lt; list3.size(); k++)
  {
  
      Result = list3.get(k);
  
      sb.append(Result.toString());
  
      sb.append(" ");
  
  }
  
  String message = sb.toString();
  
  log.info(message);
  
  sms.SendMessage("1254554555", message);
  
  es.SendMail("abcdr@gmail.com", " Server process is down", message);
  </code></pre>
  
  <p>This is my Timer class.</p>
  
  <pre><code>int delay = 5000; // delay for 5 sec.
  
  int interval = 1000; // iterate every sec.
  
  Timer timer = new Timer();
  
          timer.scheduleAtFixedRate(new sample() {
  
          }, delay, interval);
  </code></pre>
  
  <p>The Timer is Execute the <code>sample()</code> class for Every seconds and sent Email to specified Address. I want to handle the Timer will Execute for every second at the same time, the Email is sent  <code>es.SendMail("abcdr@gmail.com", " Server process is down", message);</code>  if <code>message</code> contains values is different.</p>