Skip to content
Advertisement

In Java, how to pass the objects back to Main thread from worker threads?

In Java, how to pass the objects back to Main thread from worker threads? Take the following codes as an example:

JavaScript

How to pass the result back to main‘s results[i] ?

How about passing this to WorkerThread,

JavaScript

so that it could

JavaScript

Advertisement

Answer

Why don’t you use Callables and an ExecutorService?

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement