aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes RMI multithreading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "RMI multithreading" Watch "RMI multithreading" New topic
Author

RMI multithreading

K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2531
    
    8

Hi all, I have a question. Is multithreading build into RMI already? Do I need to cater for this specifically on my RMI server? I asked this because once I get my RMI server running, I don't seem to get any output to the console when clients connect like printing "there are x clients connected". Thanks


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Alex Belisle Turcot
Ranch Hand

Joined: Apr 26, 2005
Posts: 516
K. Tsang wrote:Hi all, I have a question. Is multithreading build into RMI already? Do I need to cater for this specifically on my RMI server? I asked this because once I get my RMI server running, I don't seem to get any output to the console when clients connect like printing "there are x clients connected". Thanks

Hi,

I'm not sure I understand entirely your question.. Let me try to go trough a sequential scenario:

- You start your RMI Registry;
- You start your server;
- You bind an Object from your server into the Registry (this will be the Remote object);
- You start several clients;
- Several clients can get a reference to your remote object from the RMI Registry;
- Multiple threads will be started/used by the RMI runtime upon concurrent call of a method on the remote object;
- It is up to RMI to reuse a Thread or create a new one when a request is made (and ultimately destroy it).

Does this helps ?

Alex
Fernando Franzini
Ranch Hand

Joined: Jan 09, 2009
Posts: 486
    
    2

Hi Alex....Let me asked somenthing about RMI....there will we only one instance object bind inside RMI control and many remote proxy references ? .....like servlet inside servlet container ?


Fernando Franzini - Java Blog
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2531
    
    8

thanks Alex, from your description and the look of things, RMI is multithreaded already.

The thing I hope to do for my RMI server is to display messages as clients connect.




Alex Belisle Turcot
Ranch Hand

Joined: Apr 26, 2005
Posts: 516
K. Tsang wrote:thanks Alex, from your description and the look of things, RMI is multithreaded already.

The thing I hope to do for my RMI server is to display messages as clients connect.







I'm not sure if your server can tell if a client gets a reference to your object..
I guess you should add a method on your remote class and have each client calling it..

something like:


Regards,
Alex
Alex Belisle Turcot
Ranch Hand

Joined: Apr 26, 2005
Posts: 516
Fernando Franzini wrote:Hi Alex....Let me asked somenthing about RMI....there will we only one instance object bind inside RMI control and many remote proxy references ? .....like servlet inside servlet container ?


That's exactly my understanding, the server instantiate an object and makes it available through the RMI Registry. Sor sure, any client requesting a reference will get the same one.

I know what you mean with the servlet example, but in my opinion the concept is not the same. With Servlet, the clients don't really hold a reference to it and there *could* be different servlet handling requests from different clients based on the webapp configuration.. Anyway, I don't want to argue on semantic, I think you get it..

A similar concept (as RMI) would be EJB Stateful Session bean..

Regards,
Alex
Fernando Franzini
Ranch Hand

Joined: Jan 09, 2009
Posts: 486
    
    2

yes Alex...I agree with you...Like stateful EJB !!.
see yah.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: RMI multithreading