Pergunta

In my Callable code I use signaling to notify multiple ending behaviours to another thread. The Callable objects are queued up with FutureTasks in an Executor. They may also be cancelled after being queued up.

Now, my problem is that I rely on the tasks atleast being started for my signaling to work, but it looks like the Executor just skips a task if it's been marked as canceled before it got a chance to run it.

So, is there a way to garantee that a task is always started, and always cancelled (by InterruptedException) while running.

Also, can you check if a task has not started but failed?

Foi útil?

Solução

You can probably subclass FutureTask class and override its done() method to perform the signalling. According to the documentation, this method should be called even if the task has been cancelled.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top