public class Main {
public static class Mycallable implements callable<integer>{
Public Integer Call () throws Exception {
return 1;
}
}
public static void Main (string[] args) {
Mycallable callable=new mycallable ();
Futuretask<integer> task=new futuretask<integer> (callable);
Thread t=new thread (Task);
try {
T.start ();
System.out.println (Task.get ());
} catch (Interruptedexception e) {
TODO auto-generated Catch block
E.printstacktrace ();
} catch (Executionexception e) {
TODO auto-generated Catch block
E.printstacktrace ();
}
}
Operating system allocation thread execution is random. Then there is no possibility of first performing the ' System.out.println (Task.get ()); '. The main thread relies on the value of this worker thread. Then will not appear first executed the main thread it?
Answer address
"Face question" JAVA one thread relies on the results of another thread