From the course: Complete Guide to Spring MVC
Unlock this course with a free trial
Join today to access over 24,600 courses taught by industry experts.
Callable - Spring Tutorial
From the course: Complete Guide to Spring MVC
Callable
- [Instructor] Callable. In Java, the Callable interface represents a task. A task that can do two things: Return a result, or Support asynchronous execution. Unlike Runnable, which you may be used to, it could return a value after execution. For asynchronous execution, this can allow tasks to be executed in a separate thread with the result retrieved later. When using a Spring MVC controller, a Callable enables asynchronous processing by delegating task execution to a separate thread. The way that it works is it starts off with asynchronous execution. The Callable is submitted to an asynchronous task executor, freeing the main thread for other tasks. Next, it has result retrieval. Once the Callable's call method completes, the result is returned. And finally there's Response Sending. Spring MVC sends the result back to the client. Callable is a simpler alternative to DeferredResult. As you hear me explaining it, you may think, "What's the difference between "Callable and…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.