Updating time...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    Updating time...

    I am planning to add a clock on my program....

    My idea is to implement it using ExecutorService ....

    Im planning also to have a new Runnable...
    That will update the Clock and execute it from ExecutorService ....

    Im not sure of my plans as of now....

    Is this possible?
    If it is, will the performance of my program slows down?
    Because, i think that updating the clock is to have a reasonable infinite loop with a minimum delay time interval....

    Can you advice me experts about this?
    Any algorithm?

    Waiting for your replies,
    sukatoa....
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    The most accurate time you have on your system is from System.currentT imeMillis() .
    Call that method periodically (Thread.sleep(1 000) comes to mind) and convert
    those milli seconds to an hour/minutes/seconds form and display it.

    Especially that sleep(1000) call makes the loop quite cheap (it passes control
    to other threads).

    kind regards,

    Jos

    Comment

    • sukatoa
      Contributor
      • Nov 2007
      • 539

      #3
      Originally posted by JosAH
      The most accurate time you have on your system is from System.currentT imeMillis() .
      Call that method periodically (Thread.sleep(1 000) comes to mind) and convert
      those milli seconds to an hour/minutes/seconds form and display it.

      Especially that sleep(1000) call makes the loop quite cheap (it passes control
      to other threads).

      kind regards,

      Jos
      ........Roger.. ........

      Comment

      Working...