This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
anuj guptaa wrote:But I would like to know a real life example for the Callable interface as i have mostly used Runnable in my projects.
A Callable is just like a Runnable, except it returns a value. It is used to provide a simple, Runnable-like API to insert your executable code into FutureTasks, where some return value is expected. Internally, FutureTask probably makes use of Runnable to execute the code, but in addition, will do something with the results (such as notify get()ers that it is ready).
Real-world use would be any long task that produces a result - get something from a database and turn it into an Object, make a long calculation with a result, query a web application, get some data, do something with that data, generate output...
Joined: Aug 05, 2013
Thanks Steve!! Hope i will soon get a chance to use callable in my project..