Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RMI + threading question

Status
Not open for further replies.

stemy

Programmer
Aug 25, 2001
39
IL
Hi
I have a problem.
Let's say I have a method "public int foo()" on a remote object, and I want to enable multiple invocations of that method my multiple clients.
My Idea was assigning a new Thread each the method is invoked and letting the thread handle it.
like this:
public int foo()
{
new MyThread().start();
}


public class MyThread extends Thread
{
..
public void run()
{
...(code for method)
}
}

my problem is, how do I return the value of the method from the thread ? I don't want to wait in the method until the Thread finishes, because then I might as well not used a Thread. is there a way to do that ?

Thanx.
 
Code:
interface fooer{
	public int foo();
}

class myfoo implements fooer{
	public int foo(){
		// does whatever
		return 1;
	}
	public void somefunction(){
		new MyThread(this);
	}
}

public class MyThread extends Thread
{
   protected foo _myfoo;
	MyThread(foo f){ 
		_myfoo = f;
		start();
	}
   public void run()
   {
		_myfoo.whatever();
   }
}

-pete
I just can't seem to get back my IntelliSense
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top