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 9018101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:26:13+00:00 2026-06-16T04:26:13+00:00

I have a break timer application. It uses a timer class to keep time

  • 0

I have a break timer application. It uses a timer class to keep time and notify me via text message when my break is over. It all works, except it sends me a text message every second once the if statement becomes true. So I got about 60 messages in a minute and it will keep going while it is running. I have tried rewriting the if statement many different ways and it still does the same thing. I know that there is no such thing as if loops but that is what it is doing. the now variable is outside the timer loop, declared in the public class. I post most of the classes code below.

     private static long now = System.currentTimeMillis();
       public BreakTimer() {
        this.setText(when());
    }
     public void actionPerformed(ActionEvent ae) {
     (some more code)            
        long currenttime = System.currentTimeMillis() - now;
        int breaknotify = 15 - SettingsIni.breaknotifytime();

                    if ((currenttime) /6000 == breaknotify){                                    
                            try {
                                TextMessage.main(null);
                            } catch (AddressException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            } catch (MessagingException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }               
                    }       
        }
public void start() {
        BreakTimer.reset();
        timer.start();     
    }
    public static void main(String[] args) {
        running = true;
        BreakTimer jtl = new BreakTimer();
        jtl.start();
    }
}
  • 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-06-16T04:26:14+00:00Added an answer on June 16, 2026 at 4:26 am

    You need to stop the timer when the first text message is sent. The Timer class has a stop() method for this.

       if ((currenttime) /6000 == breaknotify){                                    
              try {
                  TextMessage.main(null);
                  //stop the timer here
               } catch (AddressException e) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application which uses URLs that look like this: http://library.example.com/Register.aspx?query=academic&key=586c70bb-5683-419c-aae9-e596af9ab66a (The
I have an application that uses Windows.Forms.Panel to display a list of pictures. When
I do have 4 ToggleButtons in my application. All of them are for looping
I have an application that uses several instances of getJSON, and I'm getting into
I have a static Settings class where my application can retrieve settings from. The
I have an application which updates my datagrid each time a log file that
I have a Flash application that creates a sort of powerpoint presentation. All the
I've an MVVM-lite application that I'd like to have unit testable. The model uses
I have an application that uses the bluetooth to receive some data (bytes) from
I have an ASP.NET application that uses Session.SessionID to prevent multiple users viewing the

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.