• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RMI Thread Spawning.

 
Ranch Hand
Posts: 531
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, guys. I am working on my Developer's Certification, aided in this task by Habibi's great book. I finally got to the point where I understand the need for adapter class and the actual remote class, and find the whole setup very elegant and simple.

But I've got a question from the area of RMI. I, from reading about RMI, understood that once a request comes in via the RMI server, the server automatically spawns a thread for each client. The programmer need not concern himself with explicitly writing thread code to handle multiple clients. The RMI creates threads automatically.

I was just going to ask for your input: if my understanding was indeed on the mark, or if I missed something.

And as always, I don't mean to ask elementary questions, but, unfortunately, I can't figure it out to certainty myself.

Thanks for your valuable time!
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Anton,

Yes, RMI will automatically create new threads (or reuse existing threads) to handle incomming calls. So you do not have to write any special code to make your server handle multiple simultaneous clients.

This means that you must write all your server code to be thread safe.

One thing you need to be aware of though, is that there is no guarantees that the thread a particular client uses for one method call will be the same thread it uses for a later method call. It is possible that client 'A' will use one thread to call lock() and a different thread to call unlock(). Or client A could use one thread to call lock() and client B could use the same thread to call lock(). (This may not bother you if you are using thin clients or if you are using lock cookies).

Regards, Andrew
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic