I have a method in my application that I want it to be called repeatedly depending on what the user selects. for example, if the user selects each hour, the action launches a method that is called every hour. I would like to know how best to plan this recurring task.
I experimented with timer and timer jobs, but for some reason it doesn't work when I use the java calendar class with it, for example:
Calendar c1 = Calendar.getInstance();
c1.add(Calendar.SECOND, 30);
updateTimer.scheduleAtFixedRate(cleanCompletedCache, c1.getTimeInMillis(),hour );
and from what I read, Handlers are not suitable for this multithreaded task. I would have to use an alarm manager for this, and why would this code not execute correctly? thank
source
share