• 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

Need some clarification on locking

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm working the urlybird developer project and I have a question about locking.

The instructions given to me state that I can assume that at any moment, only one program is accessing the database file, therefore the locking system only needs to be concerned with multiple concurrent clients of my server.

Question 1) I'm not sure what the above statement really means. If I have multiple clients connected to a single server, each of the clients has a database connection to the same database file, so how can only one program be accessing the database file?

Question 2) doesn't RMI handle the threading of the client connections? In other words, when a client desires a connection to the server thru RMI, doesn't RMI create a separate thread for that connection?
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I means that there is only one server using that database file.
If several servers could be running at the same time using the same database file, you'd also have to consider file locking. This comment says that you do not have to take that into account.
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
--------------------------------------------------------------------------
Question 2) doesn't RMI handle the threading of the client connections? In other words, when a client desires a connection to the server thru RMI, doesn't RMI create a separate thread for that connection?
----------------------------------------------------------------
yes, RMI is just work like that. It is a kind of server.
 
joel smither
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm still not sure I really understand. Suppose my server does a
rebind like this: Naming.rebind(serverObjName, dbServer)

dbServer is the service that each of the clients will refer to when they
want to access the database remotely. Does RMI create a seperate thread for
client connection 1, then another thread for client connection 2, etc?

As a result, I'll have multiple threads accessing the SAME dbServer object?
Is that true?
 
dennis du
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
-------------------------------------
Does RMI create a seperate thread for
client connection 1, then another thread for client connection 2, etc?

As a result, I'll have multiple threads accessing the SAME dbServer object?
-------------------------------------
sure, so you get it.
 
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 Joel,

Did question 1 get answered to your satisfaction?

Question 2) doesn't RMI handle the threading of the client connections? In other words, when a client desires a connection to the server thru RMI, doesn't RMI create a separate thread for that connection?



Just being pendantic here - there is no guarantee that you will get a separate thread for each connection (in fact the RMI specification explicitly states that there are no guarantees regarding thread usage).

The current Sun implementation of RMI appears to maintain a pool of threads which may be used and/or reused. So the following is possible:
  • Client A calls remote lock method which runs in thread 1
  • Client B calls remote lock method which runs in thread 2
  • Client C calls remote lock method which runs in thread 1
  • Client A calls remote read which runs in thread 3
  • Client B calls remote read which runs in thread 1

  • And this is just one possibility - there are many other permutations.

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