I am using Quartz scheduler to run the some tasks at specified time.
I have created one job which takes the records from db and process it and then update the status to the db again. due to huge amount of data im using Executor threads to pickup and process records from db.
My problem is i have one joblistener for above mentioned job, jobWasExecuted() method of joblistener is invoked before executing all the threads in the job. After the threads has been started the joblistener is invoked. i want to invoke the job listener only after executing and completing all the threads in the job.
Please suggest me how to delay the joblistener to invoke jobWasExecuted() only after executing all the threads in the job .
The listener is notified of completion as soon as the job's execute() method returns. Since you're returning from the execute() method Quartz notifies the listener because it has now way to know that you have span-off other threads to do work.
If you want the listener notified when all of your spawned threads complete, then you need to not return from the execute method until they complete. Perhaps the Thread.join() method may be useful to you.