You can join() on the thread and then collect a value from a variable populated by the thread.
However I would instead investigate Executors and Futures, so you can spawn a thread via an Executor
, get a Future
and then call Future.get()
. It's a nicer, higher-level mechanism for getting results from threads.