I need to schedule a task using java in a web application.What is more important is ability to pause and resuming the schedule.I know there is TimerTask and Timer but not sure they have this pause option.I miserably failed using Quartz Scheduler neither I have time to debug that piece of code.Can anyone point to an example where a task can be scheduled,paused and resumed ?
Asked
Active
Viewed 1,181 times
3 Answers
3
I know you've had issues with Qartz
but please give it a second look and look at the CronTrigger. And as an example on pausing a task
look at this answer: Quartz Java resuming a job excecutes it many times
0
Have you tried a plain Thread which a boolean flag to to pause it?
Personally I would use ScheduledExecutorService with a flag.

Peter Lawrey
- 525,659
- 79
- 751
- 1,130
-
I am sorry I am extremely running out of time.Any examples.I know its too much to be greedy but my situation demands so.Apologies. – Harish Mar 23 '11 at 11:03
0
Fundamentally the task is your code. So until your code provides facilities to pause, other frameworks can't really help. The simplest way to provide pausing is expose a public method that just calls sleep on your thread. Now the framework may call in your public method to pause(sleep) your thread.

Suraj Chandran
- 24,433
- 12
- 63
- 94
-
-
exaclty!! thats why i said that you would have to expose a method in your task that will sleep the current thread :) – Suraj Chandran Mar 23 '11 at 11:05
-
Except the current thread would be the one that calls the method, i.e. the framework. The only thing that works is to have a method that sets a flag which the task thread checks periodically. And then it would have to call wait rather than sleep so that it can be woken up as well. – Michael Borgwardt Mar 23 '11 at 11:14
-
@Michael, so true, actually that itself was the idea...i think i should take some rest – Suraj Chandran Mar 23 '11 at 11:16