title: How to run two methods as thread one after another using ExecuterService
body: <p>I am trying to  execute two method where two methods will execute one by one after some interval, and I am using <code>ExecuterService</code>. I have implemented some portion of the code but the full functionality I could not achieve till now, here I am posting my code </p>
  
  <pre><code>public class ExampleExecuterService {
  
  private static final int MYTHREADS = 3000;
  public static void main(String[] args) throws Exception {
  
      ExecutorService executor = Executors.newFixedThreadPool(MYTHREADS);
  
      Object methodList[]={
  
              aMethod(),bMethod()
      };
  
  
      for(int i=0;i&lt;methodList.length;i++){
          Object myList = methodList[i];
          Runnable worker = new MyRunnable(myList);
          executor.execute(worker);
      }
      executor.shutdown();
      // Wait until all threads are finish
              while (!executor.isTerminated()) {
  
              }
    System.out.println("\nFinished all threads");
  
  }
  
  public static class MyRunnable implements Runnable {
  
      private Object myList=null;
  
      MyRunnable(Object myList) {
          this.myList = myList;
      }
      @Override
      public void run() {
  
  
          try{
  
              myList.wait(2000);
          }catch(Exception e){
              e.printStackTrace();
          }
      }
  
  
  }
  
  private static Object bMethod() {
      System.out.println("This is inside method a ");
      return null;
  }
  private static Object aMethod() {
  
      System.out.println("This is inside method b ");
      return null;
  }
  
  }
  </code></pre>
  
  <p>I want <code>aMethod()</code> and <code>bMethod()</code> that should run 20 seconds after and in the end the <code>executer</code> will stop. How to do that with my code. Somebody please help me.</p>