Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

@Predestroy method needs to wait for the thread to finish.

1047254Nov 4 2015 — edited Nov 4 2015

I have a stand-alone spring batch application, and I am trying to test the behavior of graceful shutdown by using @PreDestroy feature. I see that the application waits for all current processes to complete once I shutdown the application. The only exception is a poller thread and it dies halfway although the @Predestroy method is being invoked in that class. My poller thread simply implements Runnable interface. I have put a short sleep in the run method and placed a log statement before and after the sleep. While it is sleeping I have the killed the process, it never resumes the statement after the sleep statement.

Ideally, I was hoping the application will not shutdown until the thread completes it business. Please help to to resolve this issue.

Comments
Post Details
Added on Nov 4 2015
0 comments
1,147 views