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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:28:29+00:00 2026-06-09T19:28:29+00:00

I have one infinite for loop and i want to run this for loop

  • 0

I have one infinite for loop and i want to run this for loop for 20 seconds after that i want to terminate the loop so what can i do for this?

Here is my code in android:

do {
    rl += Character.toString((char) in.read());
    // Log.i("RL", "" + rl);
    if (rl.contains("<") && checkStream(rl)) {
        // Log.i("RL INSIDE", "" + rl);
        getNumerAndStatusFromRLString(rl);
        rl = "";
    }
    if (20 SECONDS COMPLETED) {
        Log.i("<rl>", "exit");
        break;
    }
} while (true);

So what can i do to check that 20 seconds is compeleted and now its time to terminate.

Any idea will be appreciated.

  • 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-09T19:28:30+00:00Added an answer on June 9, 2026 at 7:28 pm

    I think one of the options may be get time before the loop and while looping check 20 seconds elapsed or not.

    Something like below: Not sure about the efficiency.

       long startTime=   System.currentTimeMillis();
    do {
    
    ......
    
         long currTime=  System.currentTimeMillis();
         long elapsedtime = currTime - startTime;
         if(elapsedtime > 20000)
          {
          break;
          }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this loop that parses machine code and emulates the instructions as if
I have a vital infinite for loop that allows a sensor to keep updating
see i have one code like this int main () { uint32_t i ;
So I am writing an Android app and want to have a function that
Here I have one file testdec.txt . In this File Contents are like below.
I really want to have a column of inifinite length for one of the
have one time consuming step that flattens a bunch of files. basically i'd like
I have one problem with parsing *.docx document with OpenXML (C#). So, here's my
I want to have a function defined in a superclass that returns an instance
I been working on this code for a while and can't seem to get

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.