title: Looking up the system clock -- Java
body: <p>From within my thread, I'm supposed to one thing every <code>x</code> seconds. Eg. let <code>x=3</code>, and it should do that thing at seconds <code>1, 4, 7, ...</code> . </p>
  
  <p>Making the thread <code>wait()</code> for <code>x</code> seconds wouldn't do-- because it may be interrupted for other thing(s) to do during this <code>x</code> second 
  period and thus can't keep track of the time passing in between the way it is supposed to. 
  So, the thread should come up with an efficient way of getting itself know that <code>x</code> seconds has passed on the clock. </p>
  
  <p>What's the efficient way of doing that? </p>
  
  <p>The only way I have now is keep checking the system clock to find out whether it's second 1, or 4, or 7, i.e. second <code>i</code> where <code>i%3==1</code>. 
  However, this is too wasteful and isn't any good. </p>
  
  <p>What's the best way of doing this?</p>
  
  <p>TIA. </p>
  
  <p>//====================</p>
  
  <p>EDIT:</p>
  
  <p>I think it would me a method that looks up the system clock and interrupts me at every interval. </p>
  
  <p>Does Java have a method like this somewhere?</p>