Keep the timer link somewhere and use:
timer.cancel(); timer.purge();
to stop everything he does. You can put this code inside the task you are doing with a static int to count the number of times you went, for example.
private static int count = 0; public static void run() { count++; if (count >= 6) { timer.cancel(); timer.purge(); return; } ... perform task here .... }
Fritz H Sep 11 '09 at 5:28 2009-09-11 05:28
source share