What is the difference between get () and invoke () in Java 7 ForkJoinTask?

Here is the javadoc for both:

  • get (): waits, if necessary, for the computation to complete, and then retrieves its result.
  • invoke (): Starts the execution of this task, waits for it to complete if necessary and returns its result, or throws a RuntimeException or Error if the main computation did so.
+3


source to share


1 answer


get () supports intermittent and / or temporary waiting for completion and report results using Future conventions. The invoke () method is semantically equivalent to fork (); join (), but always tries to start execution on the current thread.



+3


source







All Articles