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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:27:16+00:00 2026-05-16T22:27:16+00:00

I have a requirment to run a while loop the 5 min. I looked

  • 0

I have a requirment to run a while loop the 5 min.
I looked for the timer api but I could not found to do this.
Can any one provide a code snipet for this.

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-05-16T22:27:17+00:00Added an answer on May 16, 2026 at 10:27 pm

    The easiest way will be to just check how much time has elapsed on each iteration. Example:

    final long NANOSEC_PER_SEC = 1000l*1000*1000;
    
    long startTime = System.nanoTime();
    while ((System.nanoTime()-startTime)< 5*60*NANOSEC_PER_SEC){
      // do stuff
    }
    

    This will run the loop, until more than 5 minutes have elapsed.

    Notes:

    1. The current loop iteration will always complete, so in practice it will always run for a bit more than 5 minutes.
    2. For this application System.nanoTime() is more suitable than System.currentTimeMillis() because the latter will change if the computer’s system clock is adjusted, thus throwing off the calculation. Thanks to Shloim for pointing this out.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some credential requirements for my modules in security.yml. How can i run
I have a requirment to allow Drag and Drop with out using HTML5. This
I have a serie of video files encoded in mpeg2 (I can change this
Basic Requirements I have a SL app that can be run in-browser or out-of-browser.
I have created a VBS script in Windows. I will run this script to
On the project that I'm currently working I have a requirement to run a
I have a requirement such that my program is suppose to run for a
We have a requirment which requires to have an Handler that is extended from
I have requirement to disable copy/paste/cut operations on a textbox. For this purpose I
I know I'm probably in a small minority, but I have to use my

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.