I made a thread like this one bellow:
public class MyThread implements Runnable {
private int temp;
public MyThread(int temp){
this.temp=temp;
}
Use Callable instead of a Runnable, it will return a Future that you can use to retrieve the value once it is done.
You can use a named class instead of a lambda expression if you want to.
import java.util.concurrent.*;
public class ReturnValueFromThread {
public static void main(String[] args) throws Exception {
ExecutorService executor = Executors.newSingleThreadExecutor();
Future