About 110,000 results
Open links in new tab
  1. Runnable vs. Callable in Java - Baeldung

    May 11, 2024 · Runnable is the core interface provided for representing multithreaded tasks, and Java 1.5 provided Callable as an improved version of Runnable. In this tutorial, we’ll explore the differences and the applications of both interfaces.

  2. Callable and Future in Java - GeeksforGeeks

    Jun 28, 2021 · Here is the code for an example Callable, which will return a random number after a delay of around 0 – 4 seconds. Future. When the call () method completes, answer must be stored in an object known to the main thread, so that the main thread can know about the result that the thread returned.

  3. Java Callable Example - Tpoint Tech

    Mar 17, 2025 · In order to support this feature, the Java Callable interface is used. To understand the concept of callable, one must friendly with threads and multithreading concepts. Let's observe the code snippet which implements the Callable interface and returns a random number ranging from 0 to 9 after making a delay between 0 to 4 seconds.

  4. Java Callable Future Example - HowToDoInJava

    Aug 7, 2022 · The Java Concurrency API achieves this with the following two interfaces Callable and Future. In this tutorial, we will learn to execute Callable tasks (which return a result of type Future after execution) using ExecutorService implementations in this …

  5. Java Callable Future Example - DigitalOcean

    Aug 3, 2022 · Here is a simple example of Java Callable task that returns the name of thread executing the task after one second. We are using Executor framework to execute 100 tasks in parallel and use Java Future to get the result of the submitted tasks.

  6. Java Callable and Future Tutorial - CalliCoder

    Learn the basics of Callable and Future interfaces. How to use Callable to create tasks and How to use Future to retrieve the result of a task.

  7. Java Callable and Future Tutorial - Java Guides

    Let's create an example to demonstrate how to use Callable and Future. Example: import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; class MyCallable implements Callable<Integer> { @Override ...

  8. Multi-Threading in JAVA using Callables | by Code Craft Club

    Sep 14, 2023 · For tasks that need to return data, create classes and implement the Callable interface. This interface allows tasks to return results or throw exceptions, making it suitable for...

  9. How to use Callable and Future in Java? Example Tutorial - Blogger

    Sep 17, 2023 · Here is our complete Java program to demonstrate how you can use Callable and Future together to implement asynchronous processing in Java. Once you started using a thread pool, Callable and Future, you don't need to wait for tasks to be completed, you can move on with other tasks and come back to check whether the task is completed or not.

  10. Understanding Runnable and Callable in Java: Examples and …

    Dec 18, 2024 · Runnable is suitable for tasks without results, while Callable is preferred for tasks that need to return results and handle exceptions. Understanding their differences and applications can ...

  11. Some results have been removed