title: How accurate is the task scheduling of a ScheduledThreadPoolExecutor
body: <p>I was reading <a href="https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html" rel="noreferrer">ScheduledThreadPoolExecutor JavaDoc</a> and came across the following thing:</p>
  
  <blockquote>
    <p>Delayed tasks execute no sooner than they are enabled, <strong>but without any</strong>
    <strong>real-time guarantees about when, after they are enabled, they will</strong>
    <strong>commence</strong>. Tasks scheduled for exactly the same execution time are
    enabled in first-in-first-out (FIFO) order of submission.</p>
  </blockquote>
  
  <p>So, if I write something like this:</p>
  
  <pre><code>ScheduledExecutorService ses = Executors.newScheduledThreadPool(4); //uses ScheduledThreadPoolExecutor internally
  Callable&lt;Integer&gt; c;
  //initialize c
  ses.schedule(c, 10, TimeUnit.SECONDS);
  </code></pre>
  
  <p>there's no any guarantees that the execution of the callable will start in 10 seconds after the scheduling? As far as I got, the specification allows it to execute even in hour after scheduleing (<em>without any real-time guarantees</em>, as stated in the documentation).</p>
  
  <p>How does it work in practice? Should I excepct some really long delay?</p>