title: Wait for system time to continue application
body: <p>I've written a class to continue a started JAVA application if the current second is a multiple of 5 (i.e. Calender.SECOND % 5 == 0)</p>
  
  <p>The class code is presented below, what I'm curious about is, am I doing this the right way? It doesn't seem like an elegant solution, blocking the execution like this and getting the instance over and over. </p>
  
  <pre><code>public class Synchronizer{
      private static Calendar c;
  
      public static void timeInSync(){
          do{
              c = Calendar.getInstance();
          }
          while(c.get(Calendar.SECOND) % 5 != 0);
      }
  }
  </code></pre>
  
  <p>Synchronizer.timeInSync() is called in another class's constructor and an instance of that class is created at the start of the main method. Then the application runs forever with a TimerTask that's called every 5 seconds.</p>
  
  <p>Is there a cleaner solution for synchronizing the time?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I think I did not clearly stated but what I'm looking for here is to synchronization with the system time without doing busy waiting. </p>
  
  <p>So I need to be able to get </p>
  
  <pre><code>12:19:00
  12:19:05
  12:19:10
  ...
  </code></pre>