i'm trying to 开发者_如何转开发find the best way to implement a timeout with quartz but i want to know if this framework already contains a class or interface to do it. The timeout that need to implement it's because i want to know how long have been work the job, and take the desicion of turn off the job.
Because the java platform does not provide any way to stop a thread, Quartz does not provide any way to stop a job executing on a thread.
Jobs need to take care of themselves, as Quartz can have no idea what code is in their execute() method.
I'd suggest using System.currentTimeMillis() at the beginning of your job execute() method to record the current time, and then every time through your job's main loop use it again to get the current time. Look at the difference to see if your maximum time has past,and if so break out of your main loop and exit from the execute() method.
精彩评论