Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

FBN - Multithreaded server problem

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I implemented my server using RMI. The instruction says that server should be able to serve multiple client, so you need to make your server multi threaded. However with RMI even a single instance of DataClient is able to serve multiple Users. So is it still necessary to make the server multi threaded?
I tried deploying DataServer as multi-threaded where every connection to dataserver will first get copy of DataClient, then this copy of dataClient will serve user's request. However I have to transport the entire DataClient to the user, which does not serve the purpose of RMI (wherein only stub is transported, and not the whole object). I think I am doing something horrible wrong, I just can't think of a good design to implement multi-threaded server in RMI. Any help in this respect will be greatly appreciated
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your RMI server should expose the same methods as the Data class. The server holds a single instance of the Data object and delegates calls down to the Data instance. Your stub is for the RMI server which is sent to the clients, the Data class stays put and must be thread safe.
Only one server object gets registered. All clients issue a lookup and get a reference to the same RMI server instance.
I created an interface which my Data class implements. Then I made a DataFactory class which returns the interface type. Have the RMI Server implement the same interface. Now the factory can return either an instance of a local Data class or the remote class. Your code references the interface and doesn't know the difference. The factory must determine which type to create based on the aguments passed (i.e., file, host, port).
mooooooo ..... tiny ad ....
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic