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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:48:24+00:00 2026-06-03T06:48:24+00:00

I am having a service in my application that puts a runnable (in another

  • 0

I am having a service in my application that puts a runnable (in another java file) in a thread and starts it.
That is working fine for once, but i want it to be repetitive due to a certain period.
I need a good way to handle that.
Reason why I didn’t use the answers to other questions is that I don’t want it to repeat infinity nor I know how many times it’ll repeat the task. It’ll simply stop due to a button click in the UI.

I was thinking of using a loop with a sleep and if statement. But I think that’s really bad design for my application. Is there a standard way for doing such thing?

Thanks…

  • 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-03T06:48:26+00:00Added an answer on June 3, 2026 at 6:48 am

    You can use a handler that somehow acts like a timer but I think it is better for your situation.

    You initialize it like this:

    Handler delayhandler = new Handler();
    

    Set the time it fires like this (in ms):

    delayhandler.postDelayed(mUpdateTimeTask, 500);
    

    And it calls this:

    private Runnable mUpdateTimeTask = new Runnable()
    {   public void run()
        {   // Todo
    
            // This line is necessary for the next call
            delayhandler.postDelayed(this, 100);
        }
    }
    

    You can also remove the next call with:

    delayhandler.removeCallbacks(mUpdateTimeTask);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've having a very simple WCF service (a console application for file upload). I
I have an application that runs fine on .Net 2.0 SP2, but fails to
We have a production web application that appears to be having a thread stuck
Background: I'm working on an application that already has a thread system designed. It's
I'm having the following situation: I'm building an application that requires a service. The
I am having Grails GORM based application.One web service and one website both are
Im having trouble working grabbing a dynamically created image from this service: http://opsin.ch.cam.ac.uk/opsin/USER-STRUCTURE-TO-GENERATE.png Im
The problem i'm having is that i've created a web service, and a windows
Having watched samples from Rob Conery's Kona application, I see that he is using
I have an application that is installed per-machine (since it uses a service). One

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.