ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/FutureTask.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/FutureTask.java (file contents):
Revision 1.118 by jsr166, Sat Sep 10 04:06:51 2016 UTC vs.
Revision 1.119 by jsr166, Wed Aug 16 17:18:34 2017 UTC

# Line 451 | Line 451 | public class FutureTask<V> implements Ru
451          }
452      }
453  
454 +    /**
455 +     * Returns a string representation of this FutureTask.
456 +     *
457 +     * @implSpec
458 +     * The default implementation returns a string identifying this
459 +     * FutureTask, as well as its completion state.  The state, in
460 +     * brackets, contains one of the strings {@code "Completed Normally"},
461 +     * {@code "Completed Exceptionally"}, {@code "Cancelled"}, or {@code
462 +     * "Not completed"}.
463 +     *
464 +     * @return a string representation of this FutureTask
465 +     */
466 +    public String toString() {
467 +        final String status;
468 +        switch (state) {
469 +        case NORMAL:
470 +            status = "[Completed normally]";
471 +            break;
472 +        case EXCEPTIONAL:
473 +            status = "[Completed exceptionally: " + outcome + "]";
474 +            break;
475 +        case CANCELLED:
476 +        case INTERRUPTING:
477 +        case INTERRUPTED:
478 +            status = "[Cancelled]";
479 +            break;
480 +        default:
481 +            final Callable<?> callable = this.callable;
482 +            status = (callable == null)
483 +                ? "[Not completed]"
484 +                : "[Not completed, task = " + callable + "]";
485 +        }
486 +        return super.toString() + status;
487 +    }
488 +
489      // VarHandle mechanics
490      private static final VarHandle STATE;
491      private static final VarHandle RUNNER;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines