title: How to remove/postDelayed runnables in Java?
body: <p>Upon an event, I'd like to run a task/runnable but delay it's execution in 2 seconds.</p>
  
  <p>During these 2 seconds, if the same event occurs, I'd like to remove the previous task and re-post it to run - again delayed by 2 seconds.</p>
  
  <p>An example scenario would be background compilation. When a file is saved, I'm waiting 2 seconds and start compiling the class and other, depending classes. I don't want to do it all the time - especially if there are editors that save files automatically, like IntelliJ IDEA.</p>
  
  <p>So, <strong>how can I remove/postDelayed runnables in Java</strong>, like Android's Handler (<a href="http://developer.android.com/reference/android/os/Handler.html#removeCallbacks(java.lang.Runnable)" rel="nofollow">remove</a> / <a href="http://developer.android.com/reference/android/os/Handler.html#postDelayed(java.lang.Runnable,%20long)" rel="nofollow">postDelayed</a>)?</p>