Search code examples
javajava.util.concurrentconcurrent.futures

Why does java.util.concurrent.RunnableFuture have a run() method?


As I was going through JDK 7, I found that java.util.concurrent.RunnableFuture<V> has a run method. I wonder what the significance of duplicating the same run method signature in the interface is when it already extends Runnable.

package java.util.concurrent;

public interface RunnableFuture<V> extends Runnable, Future<V> {
    /**
     * Sets this Future to the result of its computation
     * unless it has been cancelled.
     */
    void run();
}  

Solution

  • It's defined in the interface so that they can attach RunnableFuture-specific JavaDoc to it. There's no technical significance.