Saturday, 8 March 2014

Difference between Runnable Vs Callable

1. Runnable provides run method, where a thread executes the run method of Runnable. Callable provides call method, where request is submitted by Executors.

2. Run method can't return any value. Call method can return the result of the task.

3. Syntax Of run : public void run
Syntax of call: V call() throws Exception

4. Call method throws an exception, where as run can't

5. Callable was introduced in Java 1.5 to handle use-cases that Runnable does not support like returning the result of the task, throwing exceptions etc.,


Callable interface                                                 Future interface                                                 Home

No comments:

Post a Comment