What is the primary purpose of using Callable in Java?

  • To create an instance of a Runnable interface
  • To create threads that run a specific task
  • To define and execute a periodic task
  • To run tasks asynchronously and return a result
The primary purpose of using the Callable interface in Java is to run tasks asynchronously and return a result. Unlike the Runnable interface, Callable tasks can return a result or throw an exception. This is commonly used with the Executor framework for managing concurrent tasks that require results.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *