Java SE API
Callable.call()
Compute a result, possibly throwing an exception. Direct invocation is synchronous.
Formal Syntax & Structure
java syntaxjava
V call() throws ExceptionWorking Example
Example Snippetjava
import java.time.Duration;import java.util.concurrent.*;public class Main {
public static void main(String[] args) throws Exception { Callable<Integer> count = () -> 6 * 7; System.out.println(count.call()); Thread.currentThread().interrupt(); System.out.println(Thread.currentThread().isInterrupted()); System.out.println(Thread.interrupted()); System.out.println(Thread.currentThread().isInterrupted()); }}