• 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

Do we really need verify record number in lock() method

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys:
I'm wondering do I need to verify a record to see if it's a valid record number or an undeleted record in lock() method, before doing lock process.

because I already verified each record in read, update and delete method, since lock method is only used before updating a record,
such as:
lock();
update();
unlock()

since update() method will verify record too, so I think maybe there is no necessay to verify record in lock() method.

Hoping get your advice. thank you very much.
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You at the very least need to verify that the record isn't locked already...
 
mark ken
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think so, in lock() method, I used while loop to detect is the record locked or not. why I need other method to verify the record isn't looked.

Originally posted by Jeroen T Wenting:
You at the very least need to verify that the record isn't locked already...

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you using a while loop to do the detection? Are you sure you don't run the risk of deadlocking your application?

Jeremy
 
mark ken
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Jeremy:
did you read the book <SCJD Exam with J2SE 5 2nd edition>



Originally posted by Jeremy Botha:
How are you using a while loop to do the detection? Are you sure you don't run the risk of deadlocking your application?

Jeremy

 
mark ken
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anyone give me an answer. thanks
 
Jeremy Botha
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark - no, I hadn't read that book.

Hmm. I'm not sure I'd use the method you've posted; it's far easier in my opinion to make use of wait() and notify()/notifyAll(). Each to his or her own though, I guess.

Jeremy
 
Joel Salatin has signs on his property that say "Trespassers will be Impressed!" Impressive tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic