title: ScheduledExecutorService and Threads in Java
body: <p>How does scheduler work here ? Does it create a new thread in the background and execute Run method in the main thread like a callback. ? . When run method is getting executedl, is it belong to the main thread?</p>
  <pre><code> classA implements Runnable
   {
       
      public void Run()
      {
         System.out.println(Thread.currentTread().getName());
      }
      
      public static void main(String args[])
      {
        Thread.currentThread().setName(&quot;Main&quot;);
      
        ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
        scheduler.scheduleAtFixedRate(this, 250, 250, TimeUnit.MILLISECONDS);
      
      } 
  }
  </code></pre>
  <p>Thanks.</p>