title: Synchronization using System.currentTimeMillis() for timer schedule
body: <p>I want to synchronise an action across multiple Android devices. For this I have a telnet client that I can send message to them.</p>
  
  <p>Currently I send a message like <code>DoWork On 1397131360435</code> to the devices. As you can notice the last argument is timestamp.</p>
  
  <p>At the moment in my code I calculate the time difference between the given argument and use a <code>TimerTask</code> to call the method I want.</p>
  
  <p>But this doesn't work exactly like I want because of influence of network delay and the time that this command arrives at devices is a bit different which results in few milliseconds of delay between devices.</p>
  
  <p>Is there a way that I can wait for a specific timestamp and then run the method I want?</p>
  
  <p>Currently I do like this:</p>
  
  <pre><code> msDelay = Long.parseLong(args.get(2)) - System.currentTimeMillis();
  
                 //inside a listener
                 new java.util.Timer().schedule(
                          new java.util.TimerTask() {
                              @Override
                              public void run() {
                                  mySyncMethod();
  
                              }
                          },
                          msDelay
                  );
  </code></pre>
  
  <p>So what I mean is, I want to run the <code>mySincMethod</code> when the timestamp is <code>1397131360435</code>....not just its difference with local <code>System.currentTimeMillis()</code></p>