title: java.lang.IllegalStateException: Timer already cancelled even when i am creating a new instance of the class itself
body: <p>Problem statement: I have a class that has a timer in it.</p>
  
  <pre><code>class DeleteTimer {
  
      private Timer timer = new Timer();
  
      private static Timer timerStatic;
  
      public DeleteTimer(Member uid, String serverFilePath, String deleteTime) {
  
      }
  
      public static void start() {
          timerStatic.schedule(new TimerTask() {
              public void run() {
                  deleteFolder();
                  try {
                      timerStatic.cancel();
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
              private void deleteFolder() {
                  //delete a folder
                 return true;
              }
          }, 10000);
      }
  
  }
  </code></pre>
  
  <p>I have a program that creates some folders and I want that those folders to be deleted automatically after some time. the name of the folders are not fixed and hence every time I call this class, I create a new object for it.</p>
  
  <pre><code>DeleteTimer obj = new DeleteTimer();
  obj.start();
  </code></pre>
  
  <p>This works fine at first attempt, but gives <code>java.lang.IllegalStateException: Timer already cancelled</code> when I try to run it using a new object. Please help.</p>