Re: Passing result from one thread to another thread at the end of execution
From: S Manohar (sgmanohar_at_hotmail.com)
Date: 02/17/04
- Next message: Jerry Coffin: "Re: No call for Ada (was Re: Announcing new scripting/prototyping"
- Previous message: Chris: "Re: Binary byte[] buffer to hex byte[] buffer conversion"
- In reply to: sayoyo: "Passing result from one thread to another thread at the end of execution"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 16 Feb 2004 22:12:10 -0800
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" <dontwantspam@yahoo.com> wrote in message news:<k15Xb.20445$y07.617821@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
- Next message: Jerry Coffin: "Re: No call for Ada (was Re: Announcing new scripting/prototyping"
- Previous message: Chris: "Re: Binary byte[] buffer to hex byte[] buffer conversion"
- In reply to: sayoyo: "Passing result from one thread to another thread at the end of execution"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|