JavaIntermediate#concurrency

What is the difference between Callable and Runnable?

Runnable.run() returns void and cannot throw checked exceptions. Callable.call() returns a value and can throw checked exceptions; used with ExecutorService for Futures.

Example
Callable<Integer> task = () -> { return 42; };
Runnable r = () -> System.out.println("no return value");

Related Questions

1
JavaAdvanced#concurrency

Explain wait(), notify() and notifyAll().

Open
2
JavaAdvanced#design-patterns

What is the Singleton pattern? How to implement it thread-safely?

Open
3
JavaIntermediate#design-patterns#spring

What is dependency injection?

Open