• 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

threaded server?!

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the server need to be multithreaded in the FBN application? I stumbled upon a statement that reads: "You may implement your threaded server in more than one class if you choose." The "threaded server" bit intrigues me. Does the server need to span multiple threads? If yes, what do I need to do special on the server side to know when a client has established a connection? Is it possible to derive some sort of client ID to be used in locking if the server is single threaded?
Thanks!
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you use RMI for the server then the threading is taken care of for you (Yea RMI). However if you use a sockets based server then you will need to handle the threading.
Trevor
 
emil dragan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Trevor! I just realized that the RMI takes care of the multithreading in the background. My server is too simple and I was wondering whether I'm missing something.
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys! I'd coax your to re-read the RMI spec.:
A method dispatched by the RMI runtime to a remote object implementation may or may not execute in a separate thread. The RMI runtime makes no guarantees with respect to mapping remote object invocations to threads. Since remote method invocation on the same remote object may execute concurrently, a remote object implementation needs to make sure its implementation is thread-safe. (http://java.sun.com/j2se/1.3/docs/guide/rmi/spec/rmi-arch3.html)
Although ususally your suggestion works you souldn'g rely on it (unless you're not afraid to lose several points).
I'm gonna implement a ConnectionFactory and to shoulder on it responsibility for getting new connection to the DB (RMI object that in its turn implements Runnable and here works in own thread)
[This message has been edited by Roman Rytov (edited January 02, 2002).]
 
Trevor Dunn
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Roman
Of course you are right. That is what the spec says. ANd it is true you have to make your objects thread safe. But when I say RMI handles your threading I mean you do not need to write your own thread pools, or assign theads to clients etc. All these things you have to do in a socket based solution. In RMI you just have to make your objects thread safe
Trevor
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic