I don't know of any specific pattern, but the logical way would be to
create a single class that encapsulates the running of the thread AND
the result, e.g.
class abstract ThreadWithResult extends Thread {
private boolean finished=false;
private Object result=null;
public Object getResult() throws IllegalStateException{
if(finished)throw new IllegalStateException("Process incomplete");
return result;
}
public void run(){
...
result=...;
finished=true;
}
}
then
{
ThreadWithResult t=new ThreadWithResult();
t.start();
t.join();
Object r=t.getResult();
}
But there could be a more elegant way using synchronised
methods...?
"sayoyo" <do**********@yahoo.com> wrote in message news:<k1********************@news20.bellglobal.com >...
Hello:)
I wish to know if there is some pattern design that allow passing the result
of one executing thread(at the end of the execution) to another thread.
And it is possible to pass data between two threads without having a shared
variable? event-listener model will it works????
Thanks you very much!!!!
Sayoyo