Java Executors Callable() MethodThe Callable() method of Executors class returns a Callable object that, when called, runs the given task and returns null. SyntaxParameterstask - the task to run result - the result to return action - the privileged action to run Returna callable object ThrowNullPointerException Example 1Test it NowOutput: Sun Mar 17 02:29:46 IST 2019::pool-1-thread-1 Sun Mar 17 02:29:48 IST 2019::pool-1-thread-2 Sun Mar 17 02:29:48 IST 2019::pool-1-thread-3 Sun Mar 17 02:29:48 IST 2019::pool-1-thread-4 Sun Mar 17 02:29:48 IST 2019::pool-1-thread-5 Sun Mar 17 02:29:48 IST 2019::pool-1-thread-6 Sun Mar 17 02:29:48 IST 2019::pool-1-thread-7 Sun Mar 17 02:29:48 IST 2019::pool-1-thread-8 Sun Mar 17 02:29:48 IST 2019::pool-1-thread-9 Sun Mar 17 02:29:48 IST 2019::pool-1-thread-10 Example 2Test it NowOutput: ::pool-1-thread-1 ::pool-1-thread-2 ::pool-1-thread-3 ::pool-1-thread-4 ::pool-1-thread-5 Next TopicJava Executors |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India