-
Enhancement
-
Resolution: Done
-
Major
-
6.3.0.Final
-
None
-
NEW
-
NEW
The Solver thread is the thread that calls solver.solve().
Solver threads are often part of a thread pool.
A thread pool is normally destroyed before an app ends, to enforce a graceful shutdown.
solve() calls that have already started won't actually stop (in a timely manner or even ever), because the contacts says that they:
- will cancel all tasks that haven't started yet
- interrupt the threads of all tasks that have already started
Currently, optaplanner doesn't check Thread.interrupt() so they'll happily keep solving.
Proposal A
In BasicPlumbingTermination (= so in every iteration) check Thread.interrupted(). If the thread was interrupted, set it again as interrupted (as required by Java spec, see also discussion in PLANNER-402) and throw a runtime exception.
Why not an InterruptedException? That's a checked exception, which would impact our API's badly.
Proposal B
Like A), but have solve() throw InterruptedException. There goes my HelloWorld example! No thanks.
Proposal C
Like A), but instead of throwing an exception, just behave like terminateEarly() (but still leave the thread as interrupted as required by Java spec)
- relates to
-
PLANNER-402 Determine interrupt philosophy on how to deal with InterruptionException
- Resolved