PraKash
asked on
thread method return value
After completion of running a thread is it possible force a return method from the run and return it back to the calling class?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you are using Java 1.5 http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Future.html
or else you can use Doug Lee concurrent.util library (based on the same idea): http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/FutureResult.html
or else you can use Doug Lee concurrent.util library (based on the same idea): http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/FutureResult.html
:-)
Runnable yourClass = new YourClass();
new Thread(yourClass).start();
yourClass.join();
Object o = yourClass.getReturnValue()