Sets the cancelled flag on the task, throwing if the Task has already been completed.
()
| 615 | * Sets the cancelled flag on the task, throwing if the Task has already been completed. |
| 616 | */ |
| 617 | public void setCancelled() { |
| 618 | if (!trySetCancelled()) { |
| 619 | throw new IllegalStateException("Cannot cancel a completed task."); |
| 620 | } |
| 621 | } |
| 622 | |
| 623 | /** |
| 624 | * Sets the result of the Task, throwing if the Task has already been completed. |