Hi
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 abcd
, 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,
for (int i = 0; i < InActiveProcess.size(); i++)
{
if (!ActiveProcess.contains(InActiveProcess.get(i)))
{
list3.add(InActiveProcess.get(i));
}
}
for (int i = 0; i < 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 < 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("[email protected]", " Server process is down", message);
This is my Timer class.
int delay = 5000; // delay for 5 sec.
int interval = 1000; // iterate every sec.
Timer timer = new Timer();
timer.scheduleAtFixedRate(new sample() {
}, delay, interval);
The Timer is Execute the sample()
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 es.SendMail("[email protected]", " Server process is down", message);
if message
contains values is different.