title: Java: Call method by Timer, but changes made by called method dont remain outside TimerTask
body: <p>I want that a particular method is called after a certain delay. I tried different aproaches likes timer, executor or handlers. They fullfill what they are supposed to do, but with a little exception. The delayed method call makes some changes in a multimap from guava. Within the <code>run</code>-method of the TimerTask the output is like I want it. But if I print the multimap outside of <code>run</code> the changes are withdrawn and I still have the old multimap values. But I need the updated ones, because my data is saved in it and I need the updated values to work with.</p>
  
  <p>My code looks like that:</p>
  
  <pre><code>public class classTimer {
    public static void main(String[] args) {
      //some code, irrelevant for the task
  
               new Timer().schedule(new TimerTask() {          
               @Override
               public void run() {
                   dataMap = UndoManager.undoChanges(dataMap, a, hw); 
                   // Point 1  
                      }
                  }, delay);  
                  // Point 2
     }
   }
  </code></pre>
  
  <p>Like I said before, printing the <code>dataMap</code> at Point1 gives the correct output, at Point 2 the old values, like the Method <code>UndoChanges</code> was newer called. Multimaps are implemented that changes stay consistent and normally the values must have been changed, but thats not the case here. What am I missing here? If somebody knows a different method to call a method after a delay, I would be happy to hear it.</p>
  
  <p>Thanks and much appreciated</p>