What are two differences between Callable and Runnable?

What are two differences between Callable and Runnable?

What are two differences between Callable and Runnable?

A.
A callable can return a value when executing, but a Runnable cannot.

B.
A callable can be executed by a ExecutorService, but a Runnable cannot.

C.
A Callable can be passed to a Thread, but a Runnable cannot.

D.
A callable can throw an Exception when executing, but a Runnable cannot.

Explanation:
The Callable interface is similar to Runnable, in that both are designed for classes whose instances are potentially executed by another thread. A Runnable, however, does not return a result and cannot throw a checked exception.



Leave a Reply 1

Your email address will not be published. Required fields are marked *


Amol

Amol

A, D
Callable interface has a call method to Computes a result. It throws an exception if unable to Compute.