FutureTask (Java Platform SE 8 ) (original) (raw)


public class FutureTask
extends Object
implements RunnableFuture
A cancellable asynchronous computation. This class provides a base implementation of Future, with methods to start and cancel a computation, query to see if the computation is complete, and retrieve the result of the computation. The result can only be retrieved when the computation has completed; the get methods will block if the computation has not yet completed. Once the computation has completed, the computation cannot be restarted or cancelled (unless the computation is invoked usingrunAndReset()).
A FutureTask can be used to wrap a Callable orRunnable object. Because FutureTask implementsRunnable, a FutureTask can be submitted to anExecutor for execution.
In addition to serving as a standalone class, this class providesprotected functionality that may be useful when creating customized task classes.
Since:
1.5

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.