• 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

validation of the record in the lock-method

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers,

I am a little bit confused about the validation of the record in the lock- method in Data class.
I have used a Map lockedRecords where the record with the correspondent locked cookie is saved and my lock method looks like this:

Before the record will be locked, it should be checked if it is deleted or not in the database. But what is the correct time to check it: before the synchronisation block (1) or in this block (2).
(1)

(2)


Could you help me ?
any ideas are appreciated!

And thanks a lot!!
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont think you needto do either of these two (can be nice to have though).

Third option: It is more important to do this check after the while statement (just before trying to lock the record).


[ December 27, 2005: Message edited by: Ali Hussain ]
 
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Elena and Ali,

Ali said:


I dont think you needto do either of these two (can be nice to have though).

Third option: It is more important to do this check after the while statement (just before trying to lock the record).



I think it's also important to check whether the record exists before entering the synchronized block. Why to wait for the lockedRecords monitor if the record does not exist?

 
Ali Hussain
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with Alex and would do something like this:

 
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic