In this article, we will see difference between Runnable and Callable in Java.

Runnable and Callable both are interfaces in Java that support multithreaded programming. Both are implemented by classes that want to execute some code in a thread different than the main thread.

The Runnable interface has been around since around Java 1.0 whereas Callable was introduced in Java 1.5

Here is how the interfaces look like :

public interface Runnable {
void run();
}

public interface Callable<V> {
V call() throws Exception;
}

So, here are the differences:

A Runnable implementer needs to implement the run() method where as Callable implementer needs to implement the call() method.

Runnable’s run() method doesn’t take any parameters and also doesn’t have a return value. But what if you want to return something from the executing task ? In such case, you can use a Callable. The call() method allows you to return a generic value from the task. The returned value from Callable is captured in a Future object.

Therefore, one of the major difference between Runnable and Callable is that Callable allows you to capture the returned value.

In summary, you can use either of the interfaces with the Executor framework, but if you have a requirement to return any value from the task, you can choose to use Callable, otherwise you could use Runnable.