How to implement a timeout using quartz?

I am trying to find a better way to implement a timeout with quartz, but I want to know if this environment already contains a class or an interface for this. The timeout that needs to be implemented, because I want to know how long I worked on the work, and decide to turn off the work.

+6
java java-ee quartz-scheduler
source share
1 answer

Because the java platform provides no way to stop the thread, Quartz does not provide any way to stop the job in the thread.

Jobs should take care of themselves, since Quartz may not know what code is in the execute () method.

I would suggest using System.currentTimeMillis () at the beginning of your execute () method to write the current time, and then every time through the main job loop, use it again to get the current time. Look at the difference to see if your maximum time has passed, and if it comes from the main loop and exits from the execute () method.

+8
source share

All Articles