• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Have I misunderstood the locking concept?

 
Seetharaman Iyer
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm in final touch to the project. I don't know whether I misunderstood the locking concept. My lock method will lock whole database, so other thread has to wait till the thread which has locked the database release it.

My design is if thread A locked record 5, no other thread can lock any other record.

I think I've to implement like this:
If Thread A locked record 5, all other threads are allowed to lock any record other than record 5.

Please help me.

Thanks,
Seetha...

 
Carlos Morillo
Ranch Hand
Posts: 221
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Seetha,


Read the FAQ and in special here.

You need to provide logical record level locking granularity so multiple clients can access your database concurrently
and at the same time (Client A locking record 5, Client B locking record 10 and so on).

In my honest opinion, with that approach locking the entire database, you are serializing all the access to the database
and most likely you will fail or get a very, very low grade as far as the locking requirements go.


HTH,


Carlos.
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the output of the multi-threaded server would look like this (of course this output is not guaranteed, because order can change):

client1 locks rec4
client2 locks rec5
client1 updates rec4
client3 locks rec6
client3 updates rec6
client1 unlocks rec4
client2 updates rec5
client2 unlocks rec5
client3 unlocks rec6

And if a similar output is not possible with your current code, I think you'll fail because your locking mechanism is not according to the instructions. And also imagine a mix of reads and finds interfering with this scenario (so between locking of rec4 and rec5 other clients can read rec10, create rec341, find all records in Paris,...)
 
Seetharaman Iyer
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much Carlos & Roel . This really helps me a lot. I'll deal it with creating new HashMap.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic