Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>What are the differences in the applications of <code>Runnable</code> and <code>Callable</code>. Is the difference only with the return parameter present in <code>Callable</code>?</p> </blockquote> <p>Basically, yes. See the answers to <a href="https://stackoverflow.com/questions/141284/the-difference-between-the-runnable-and-callable-interfaces-in-java">this question</a>. And the <a href="http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Callable.html" rel="noreferrer">javadoc for <code>Callable</code></a>.</p> <blockquote> <p>What is the need of having both if <code>Callable</code> can do all that <code>Runnable</code> does?</p> </blockquote> <p>Because the <code>Runnable</code> interface <strong>cannot</strong> do everything that <code>Callable</code> does!</p> <p><code>Runnable</code> has been around since Java 1.0, but <code>Callable</code> was only introduced in Java 1.5 ... to handle use-cases that <code>Runnable</code> does not support. In theory, the Java team could have changed the signature of the <code>Runnable.run()</code> method, but this would have broken binary compatiblity with pre-1.5 code, requiring recoding when migrating old Java code to newer JVMs. That is a BIG NO-NO. Java strives to be backwards compatible ... and that's been one of Java's biggest selling points for business computing.</p> <p>And, obviously, there are use-cases where a task doesn't <em>need</em> to return a result or throw a checked exception. For those use-cases, using <code>Runnable</code> is more concise than using <code>Callable&lt;Void&gt;</code> and returning a dummy (<code>null</code>) value from the <code>call()</code> method.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload