Blogger

Delete comment from: Java67

Well the fact that method call() can return whatever type you want makes easy to trigger the execution of a method into a separate thread and return when the execution is over.
For example, I have been using this pattern lately to run Groovy scripts into a Java application to handle specific behaviours for some of our customers. With running the custom script (written by third parties) into separate threads, I can better control their execution (i.e. stop them if they exceed a maximum duration). Combined with the java ScriptEngine framework, all I had to do is provide with an interface that Groovy scripts had to implement, and a little code to stick all this together.

But honestly, the above article is a little poor as it doesn't provide much more information that the API javadoc.

Dec 17, 2014, 11:05:17 AM


Posted to Difference between Callable and Runnable in Java? call() vs run() method

Google apps
Main menu