Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 892929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:08:20+00:00 2026-05-15T14:08:20+00:00

Im developing the java Email application with Timer, I have a two arraylists named

  • 0

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("abcdr@gmail.com", " 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("abcdr@gmail.com", " Server process is down", message); if message contains values is different.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T14:08:21+00:00Added an answer on May 15, 2026 at 2:08 pm

    Update: The question changed after posting this answer. This is the answer to the original question:

    You can use a Timer class.

    You can schedule actions to be taken when the timer is off through a TimerTask. This class is abstract so you have to extend it and implement the method run().

    class MyTimerTask extends TimerTask {
    
       @Override
       public void run(){
       // Task to do here
     }
    }
    

    And then in your main class

    MyTimerTask task = new MyTimerTask(); // this class implements WHAT to do inside the method run();
    Date date = new Date(...) // This class will tell timer WHEN to do the task
    Timer timer = new Timer(task,date); //Good to go!
    

    Alternatively you can do Timer timer = new Timer(task,delay) to have the task executed after delay miliseconds

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a java application which will run on LAN, i do test today
I am developing a GWT application and I want to send an Email via
I'm developing Java MIDI application. And I have stuck with debugging of exception, which
I'm developing a Java EE JBoss service which will be deployed in two different
I am developing a web application using JSF and JPA(Eclipse link). I have two
We are developing a Java EE application with Spring. The application will be deployed
I´m developing a Java EE application and I'm using Struts. When I use html
I am currently developing a Java web application that exposes a web service interface.
I am developing a Java web application in Netbeans IDE 7.1.1 . The IDE
Imagine you are developing a Java EE app using Hibernate and JBoss. You have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.