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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:50:13+00:00 2026-05-15T02:50:13+00:00

https://docs.oracle.com/javase/6/docs/api/java/lang/System.html#currentTimeMillis() says: Returns the current time in milliseconds. Note that while the unit of

  • 0

https://docs.oracle.com/javase/6/docs/api/java/lang/System.html#currentTimeMillis() says:

Returns the current time in milliseconds. Note that while the unit of time of the return value is a millisecond, the granularity of the value depends on the underlying operating system and may be larger. For example, many operating systems measure time in units of tens of milliseconds.

It is not clear to me if I am guaranteed that this code will always print ever increasing (or the same) numbers.

while (1) { 
    System.out.println(System.currentTimeMillis() );
}
  • 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-15T02:50:14+00:00Added an answer on May 15, 2026 at 2:50 am

    The short answer is no, System.currentTimeMillis() is not monotonic. It is based on system time, and hence can be subject to variation either way (forward or backward) in the case of clock adjustments (e.g. via NTP).

    System.nanoTime() is monotonic, if and only if the underlying platform supports CLOCK_MONOTONIC — see the comments on Java bug report 6458294 for a good writeup on some circumstances where this is/isn’t true.

    (And, as an additional anecdote, I have personally observed (several times) System.currentTimeMillis() run ‘backwards’, in the absence of clock adjustments, across threads — that is, a call to that method in one thread returned a lower value than a call in another thread, even though it occurred chronologically after it in ‘real-time’)

    If you need a monotonic source, System.nanoTime() on a platform supporting monotonicity is your best option.

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

Sidebar

Related Questions

I was reading the JavaDoc for Threadlocal here https://docs.oracle.com/javase/1.5.0/docs/api/java/lang/ThreadLocal.html and it says ThreadLocal instances
https://docs.oracle.com/javase/1.5.0/docs/api/java/util/Arrays.html Sun does not mention any complexity for their binary-search implemention. Is this a
Here is the java package-tree: http://docs.oracle.com/javase/7/docs/api/java/lang/package-tree.html I read a tutorial on Java which stated
According to http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Class.html#getDeclaredMethods%28%29 , Class.getDeclaredMethods() should only include methods declared by the class. However,
Possible Duplicate: String and Final From http://docs.oracle.com/javase/6/docs/api/java/lang/String.html I can read that: Strings are constant;
http://docs.oracle.com/javase/6/docs/api/java/sql/Timestamp.html The only non-deprecated ctor takes millis. Is there no way to ask for
The result set I'm speaking of this: http://docs.oracle.com/javase/1.4.2/docs/api/java/sql/ResultSet.html What I would like to do
http://weblogs.java.net/blog/aim/archive/2007/07/embedding_swing.html http://docs.oracle.com/javase/1.5.0/docs/api/index.html?javax/swing/text/html/ObjectView.html I add html code to JEditorPane: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
According to doc, calendar set() is: http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Calendar.html#set%28int,%20int,%20int%29 set(int year, int month, int date) Sets
I'm currently looking at the EventQueue class on the Oracle website: http://download.oracle.com/javase/1.4.2/docs/api/java/awt/EventQueue.html But I'm

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.