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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 471k
  • Answers 471k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Hmmm...will ensureInjected() do what I want? Can I just define… May 16, 2026 at 3:15 am
  • Editorial Team
    Editorial Team added an answer Have you looked into http://drupal.org/project/Custom_Search? Not sure if it will… May 16, 2026 at 3:15 am
  • Editorial Team
    Editorial Team added an answer V3 does not have tabbed infowindows, yet. May 16, 2026 at 3:15 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.