Results 1 to 3 of 3
  1. #1
    _max_ is offline Member
    Join Date
    Jul 2011
    Posts
    9
    Rep Power
    0

    Smile High resolution CLOCK

    Dear friends,

    I need to write a very simple application to show a digital clock on a big monitor for a conference Hall.

    What I need is only an high accuracy. The clock should give a precise feedback to talkers, in terms of remaining time, considering that any lesson should vary between 5 minutes to 45 minutes. Even seconds are precious.

    Any idea to handle such a clock?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default Re: High resolution CLOCK

    You want to measure a second as accurate a possible; I do it like this: let 'cur' be the time measured in milliseconds at the last measurement point:

    1) sleep for +- 900 milliseconds
    2) set newCur= System.currentMillis();
    3) if newCur-1000 < cur goto step 2;
    4) cur= newCur

    This way your program sleeps most of the time (which is cheap) and it hogs the processor for the last bit (step 2 and step 3)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    _max_ is offline Member
    Join Date
    Jul 2011
    Posts
    9
    Rep Power
    0

    Default Re: High resolution CLOCK

    Quote Originally Posted by JosAH View Post
    You want to measure a second as accurate a possible; I do it like this: let 'cur' be the time measured in milliseconds at the last measurement point:

    1) sleep for +- 900 milliseconds
    2) set newCur= System.currentMillis();
    3) if newCur-1000 < cur goto step 2;
    4) cur= newCur

    This way your program sleeps most of the time (which is cheap) and it hogs the processor for the last bit (step 2 and step 3)

    kind regards,

    Jos
    Hi JosAH,

    many thanks for your quick reply with the algorithm. I will try the code soon and I will be back with my notes, if any

Similar Threads

  1. 24 hour clock to 12 hour clock project.
    By bs3ac in forum New To Java
    Replies: 4
    Last Post: 01-08-2013, 10:10 AM
  2. Best resolution timer
    By tabchas in forum New To Java
    Replies: 11
    Last Post: 06-14-2011, 03:15 PM
  3. Resolution problem!
    By jan1ey in forum New To Java
    Replies: 1
    Last Post: 03-03-2009, 07:36 AM
  4. What's Your New Year's Resolution?
    By CaptainMorgan in forum Forum Lobby
    Replies: 4
    Last Post: 11-16-2008, 09:05 PM
  5. How to change the resolution ?
    By samson in forum Java 2D
    Replies: 1
    Last Post: 07-17-2007, 11:15 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •