Menu Bar

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Sunday, 4 December 2016

What is the difference between Runnable and Callable Interface in Java ?



Difference between Runnable and Callable Interface in Java ?

Runnable
Callable
Runnable introduce from JDK 1.0.
Callable introduce from JDK 5.0.
Runnable has run() method.
Callable has call() method.
Runnable run() method does not return any value, because its return type is void.
Callable call() method return value.

Runnable run() method does not throw any Exception(Checked Exception).
Callable call() method throw Exception(Checked Exception).
To execute runnable instance we pass its instance in Thread class object.
To execute callable instance we have to use ExecutorService interface of Executor framework.
Declaration of Runnable :
Declaration of Callable :
public interface Runnable {
            void run();
}
public interface Callable<V> {
            v call() throws Exception;
}
      


Blog Author - Pushkar Khosla,
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.

This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.



Share this Blog with yours Friends !!

No comments:

Post a Comment