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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:25:43+00:00 2026-06-17T06:25:43+00:00

Is there some known issue with this executor? Or am I using it wrong

  • 0

Is there some known issue with this executor? Or am I using it wrong way? I need to schedule uploads in separate thread and I want the next upload to fire after a certain time after current upload had finished.

So there are some code excerpts from my Service implementation:

ScheduledExecutorService periodicUploadExecutor;

@Override
public void onCreate() {
    super.onCreate();

    // some stuff...

    periodicUploadExecutor = Executors.newSingleThreadScheduledExecutor();
    periodicUploadExecutor.schedule(uploadPointsToServer, getCurrentUploadIntervalInMs(), TimeUnit.MILLISECONDS);
}

private Runnable uploadPointsToServer = new Runnable() {
    public void run() {

        Log.d("SOMETAG", "--->>>  UPLOAD runnable started!");

        // upload stuff here...

        Log.d("SOMETAG", " upload runnable scheduling next after "+getCurrentUploadIntervalInMs());
        periodicUploadExecutor.schedule(uploadPointsToServer, getCurrentUploadIntervalInMs(), TimeUnit.MILLISECONDS);

        Log.d("SOMETAG", "<<<---  upload runnable ENDED!");
    }
}

private final int getCurrentActiveSampIntervalInMs() {
    return 300000; // just an example
}

But as I examine the logs I see the following:

01-08 15:33:42.166 D/SOMETAG ( 4606): --->>>  UPLOAD runnable started!
01-08 15:33:43.166 D/SOMETAG ( 4606):  upload runnable scheduling next after 300000
01-08 15:33:43.166 D/SOMETAG ( 4606): <<<---  upload runnable ENDED!
01-08 15:38:43.166 D/SOMETAG ( 4606): --->>>  UPLOAD runnable started!
01-08 15:38:44.174 D/SOMETAG ( 4606):  upload runnable scheduling next after 300000
01-08 15:38:44.174 D/SOMETAG ( 4606): <<<---  upload runnable ENDED!
01-08 15:43:44.174 D/SOMETAG ( 4606): --->>>  UPLOAD runnable started!
01-08 15:43:45.143 D/SOMETAG ( 4606):  upload runnable scheduling next after 300000
01-08 15:43:45.143 D/SOMETAG ( 4606): <<<---  upload runnable ENDED!
01-08 16:01:38.887 D/SOMETAG ( 4606): --->>>  UPLOAD runnable started!

So first three go well but the last one starts after eighteen minutes, not five! This service also gets location updates between 15:43 and 16:01, but location listener operates on main thread and there are few seconds long periods between location updates so nothing should block scheduled executor to fire… but it is late by more than three times the scheduled delay! How’s that possible?

  • 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-17T06:25:44+00:00Added an answer on June 17, 2026 at 6:25 am

    You need to use AlarmManager instead of Executor/handler or use a Partial Wakelock to keep the cpu on.

    If cpu is in sleep mode, your app will not run until phone wakes up.
    AFAIK only AlarmManager can get you a callback by waking up the device. For this you need to use either ELAPSED_REALTIME_WAKEUP or RTC_WAKEUP type, other options will again result in delay.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that there are some threads have a similar issue with this thread.
I'm pretty sure this is a known issue and there is some info about
This is a known issue - when files are added using Ankh, they are
There is a known issue with using jquery fadeOut, fadeIn, and fadeToggle, when fading
I just want to know if there is any known issue, or if I'm
I would like to know if there is some way to access the values
Is there a known issue leading to file modification times of cache files on
There is a wide known issue with printing of Flash content in Firefox and
there is known issue with loading a flot chart in a jquery tab that
It's a well known issue this damn error expected class-name before ‘{’ token Well,

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.