title: In Java, is there a way to check if Runnable is completed in single thread?
body: <p>In Java, I need to get two parameters, Runnable and Delay in milliseconds, and need to run the Runnable in the delay time. This needs to be run in single thread, and if the method is invoked with different parameter values and the previous task has not finished, it should be kept in a queue.</p>
  <pre><code>public void runScheduledTask(Runnable task, long delay) {
     // ...
  }
  
  ...
  
  runScheduledTask(task1, 10); // at 00:00:00.000
  runScheduledTask(task2, 10); // at 00:00:00.005
  </code></pre>
  <p>when the method is invoked with task2, task1 has not started/finished yet as there is delay 10, so task2 should be stored in queue.
  Is there a way that I can check if the task1 has completed in this case?
  As this should be run in the current thread, I have no idea what classes or tools I can use.</p>