Losing unprocessed records when blocking queue entries are serialized
Hi,
I am developing a batch framework using the Java 1.5 thread APIs. We have a requirement to save the state of the batch processes when it terminates abnormally or when it is killed for any reason. I have implemented this functionality using shutdown hooks.
I have initialized the thread pool with two thread instances. Now, while things are behaving as expected, I am losing upto 2 records when I kill the batch process. These are those 2 records which were being processed by the threadpool threads when the kill signal was sent.
Is there a mechanism to prevent the batch job from exiting before these two threads have processed finishing or maybe keep these 2 threadpool tasks in the pool till they have completed gracefully. I.e. remove these tasks from the threadpool task queue when have they have finished execution
Regards,
Hitesh

