Share:- Whatsapp Facebook Facebook

------------------------------------- Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.

What is the difference between runnable and callable in java

0 votes
96 views
What is the difference between runnable and callable in java?
asked Dec 15, 2015 in Java by Manish Jain

1 Answer

0 votes

The difference between runnable and callable in java is very important interview question. It is generally asked by interviewer.

See the following difference between runnable and callable:-

  • Callable is an interface which is added in java 5. So, Callable interface is newer than Runnable interface.
  • Runnable interface has run() method to perform some tasks while Callable interface has call() method to perform task.
  • run() method of Runnable interface does not return any value, It's return type is void. And call() method of Callable interface returns value. Callable interface is a generic parameterized interface and Type of value is provided, when instance of Callable implementation is created.
  • run() method can not throw checked exception, while call() method can throw checked exception.
  • public interface Runnable {
        void run();
    }

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

answered Jan 27, 2016 by john12 (3,120 points)
...