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

Comparing jsr166/src/jdk8/java/util/concurrent/FutureTask.java (file contents):
Revision 1.1 by jsr166, Sat Mar 26 06:22:50 2016 UTC vs.
Revision 1.2 by jsr166, Tue Sep 26 03:44:53 2017 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines