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

The Archive Base Latest Questions

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

I use java.util.Timer to trigger jobs in my app, but I found that it

  • 0

I use java.util.Timer to trigger jobs in my app, but I found that it is depend on system time: if system time is adjusted, timer’s trigger will be affected.

For example, if system time goes back by 80 seconds, the timer will stop working for 80 seconds.

Java has a System.nanoTime method which is independent of system time, but it seems that it
cannot be used in Timer.

Is there Timer library that supports what I need? Or I have to implement it myself?

Notice that I don’t need a precise current time(date), I need a precise time interval

  • 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-27T22:22:44+00:00Added an answer on May 27, 2026 at 10:22 pm

    you have 2 options:

    • Write your one timer, relatively trivial. Before anyone tell reinvent the wheel, being able to carry the task yourself is always important. Especially when it’s around 20 lines of code.
    • Use java.util.concurrent.ScheduledThreadPoolExecturor and use scheduleAtFixedRate, the queue impl. is based on System.nanoTime.
    • Install ntp daemon that adjusts the time by tuning (slowing down, speeding up) the system clock in very slight fashion during long time span.

    Few other things, perfect 100ms is a tall order in non-real time GC environment as GC may STW (stop the world) for seconds sometimes. Sun’s GCs can’t do that super reliably. IBM’s Metronome running on modified Linux kernel is supposed to be able to. You may wish to pay attention to if your application is truly real-time demanding.

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

Sidebar

Related Questions

Every class that wants to use java.util.logging generally needs to declare a logger like
I want to use the java.util.Preferences API but I don't want my program to
I want to use java.util.ConcurrentLinkedQueue as a non-durable queue for a Servlet. Here's the
Can I use java.util.Properties with encoding different then default?
I'm trying to figure out how to use the java.util.logging features. All of the
I am a complete JSP beginner. I am trying to use a java.util.List in
I mostly use Java and generics are relatively new. I keep reading that Java
I have a big project that also use many libraries. With jstack I found
I am trying to use futures for the first time. It seems smart that
For my Android application there is a timer that measures how much time has

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.