Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
    
  
  
  
  
    
  
  
    
    
  
  
RunnableFuture
  public
  
  
  
  interface
  RunnableFuture
  
  
      implements
      
        Future<V>, 
      
        Runnable
      
  
  
  
    
    | java.util.concurrent.RunnableFuture<V> | 
  
  
  
    
      | 
          Known indirect subclasses
          
  
  
         | 
  
    
  A Future that is Runnable. Successful execution of
 the run method causes completion of the Future
 and allows access to its results.
  
Summary
| Public methods | 
|---|
  
  
  
    | 
        abstract
        
        
        
        
        void | 
      run()
      Sets this Future to the result of its computation
 unless it has been cancelled.
        
    
 | 
  
| Inherited methods | 
|---|
| 
    From interface
      
        
          java.util.concurrent.Future
        
      
      
  
  
  
    | 
        abstract
        
        
        
        
        boolean | 
      cancel(boolean mayInterruptIfRunning)
      Attempts to cancel execution of this task.
        
    
 |  
  
  
    | 
        
        default
        
        
        
        Throwable | 
      exceptionNow()
      Returns the exception thrown by the task, without waiting.
        
    
 |  
  
  
    | 
        abstract
        
        
        
        
        V | 
      get(long timeout, TimeUnit unit)
      Waits if necessary for at most the given time for the computation
 to complete, and then retrieves its result, if available.
        
    
 |  
  
  
    | 
        abstract
        
        
        
        
        V | 
      get()
      Waits if necessary for the computation to complete, and then
 retrieves its result.
        
    
 |  
  
  
    | 
        abstract
        
        
        
        
        boolean | 
      isCancelled()
      Returns trueif this task was cancelled before it completed
 normally. |  
  
  
    | 
        abstract
        
        
        
        
        boolean | 
      isDone()
      Returns trueif this task completed. |  
  
  
    | 
        
        default
        
        
        
        V | 
      resultNow()
      Returns the computed result, without waiting.
        
    
 |  
  
  
    | 
        
        default
        
        
        
        Future.State | 
      state()
      
        
    
 |  | 
| 
    From interface
      
        
          java.lang.Runnable
        
      
      
  
  
  
    | 
        abstract
        
        
        
        
        void | 
      run()
      When an object implementing interface Runnableis used
 to create a thread, starting the thread causes the object'srunmethod to be called in that separately executing
 thread. |  | 
Public methods
    run
    
public abstract void run ()
    
    
    
  Sets this Future to the result of its computation
 unless it has been cancelled.
 
 
 
  
  
    
  
 
  
    
    
      
       
    
    
  
  
  Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
  Last updated 2025-03-13 UTC.
  
  
  
    
      [null,null,["Last updated 2025-03-13 UTC."],[],[]]