Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Question on lock()/unlock()

John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a little confused about lock/unlock methods. Because the assignment already provide modify() and delete() methods, and they are synchronized. Acoording to Sun assignment, when user want to book flight, the only requirement is the seat number get deducted.
So what if for booking flight purpose, I just overload the modify() method, supply the same record but deducted seat number. Since these methods are already thread safe for the same Data object. So what is the need for lock()/unlock()?
Could anyone provide a scenario on how lock/unlock work?
Thanks in advance!
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!