JPPF Issue Tracker
Please log in to bookmark issues
CLOSED  Enhancement JPPF-355  -  Add an "interruptible" flag to the tasks
Posted Dec 19, 2014 - updated Aug 15, 2018
icon_info.png This issue has been closed with status "Closed" and resolution "RESOLVED".
Issue details
  • Type of issue
  • Status
  • Assigned to
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
  • Posted by
  • Owned by
    Not owned by anyone
  • Category
  • Resolution
  • Priority
  • Targetted for
    icon_milestones.png JPPF 4.2.x
Issue description
Some times, it is not desirable that the execution of the run() method of a task be interrupted upon a cancellation request. For instance, the task could be exchanging data with a remote server using interruptible I/O, and interrupting at this time could cause data integrity issues.

We propose to give the tasks the ability to chose the behavior whenever they are cancelled or time out, by adding an "interruptible" flag to Task<T> and AbstractTask<T>. When the interruptible flag is false, then the thread shall not be interrupted when the task is cancelled or times out. For backaward compatibility with previous versions, the flag shall be true by default.

Comment posted by
Dec 19, 10:50

Proposed implementation  ⇑ top

Since this has been requested for the current version (4.2.x), I'm turning this ticket into an enhancement, so it can be delivered in a maintenance release. The proposed design is as follows:

We create an interface named "Interruptibility" as follows, to be implemented by the tasks:
public interface Interruptibility {
  boolean isInterruptible();
In the 4.2 branch, users will have to implement the interface in their tasks if they want to control whether the task can be interrupted. In the trunk, Task<T> will extend this interface and AbstractTask<T> will have an implementation of isInterruptible() which returns true. To return a different value, users will have to override that method in subclasses.

By doing this, we ensure that we can use the same code to check interruptibility of a task in 4.2 and trunk, while not breaking anything in 4.2, since adding anything to Task and AbstractTask encurs the risk of breaking serialization between 4.2 maintenance releases.
Comment posted by
Dec 20, 20:01
implemented in: