Java: How to use Timer class to call a method, do something, reset timer, repeat?
<p>Sorry for asking such a basic question, but I am a Java beginner and have been futzing around with various solutions to this problem and have gotten myself kind of knotted up.  I've tried with Threads and then discovered this Timer class and have messed around with it without success so far.  If you could post <strong>executable code with a main method</strong> so I could see it working and start playing around from there, that would be great.  Thanks.</p>

<ol>
<li>Launch program</li>
<li>call doSomething() method
 //</li>
<li>Generate random number and set Timer for that long.</li>
<li>When Timer goes off, call doSomething again.</li>
</ol>

<p>Probably using this (or??): <a href="http://docs.oracle.com/javase/6/docs/api/java/util/Timer.html" rel="nofollow">http://docs.oracle.com/javase/6/docs/api/java/util/Timer.html</a></p>
