Here is the situation, I am writing a framework for a code war contest. As you run the code for each move, it calls the library method provided by each member. Competition rules are a method that should return in 1 second or we kill the task that causes them. Then we use the default result for this reversal.
The method does not support cancellation, because we cannot trust the called code to respond to cancellation. And we need to kill the thread, because if we have 10 or 20 ignored background tasks, then all the calls going forward will provide fewer clock cycles for each call and the methods that used to take less than 1 second now require more.
On the plus side, the method we are killing should not open resources, etc., so an interrupt should not leave anything hanging.
Update: There are two things to keep in mind here. Firstly, it looks like a game, so performance is important. Secondly, the workflow is unlikely to open any resources. If one of the called methods is out of bounds, I need to cancel it and go quickly.
source share