Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URLBirdy(1.3.2) Lock and Unlock method

 
vijay selvaganapathy
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
I have the foll. questions


// Locks a record so that it can only be updated or deleted by this client.
// If the specified record is already locked, the current thread gives up
// the CPU and consumes no CPU cycles until the record is unlocked.
public void lock(int recNo) throws RecordNotFoundException;

1) Do we have to sychronize the whole lock method or just synchronize only on the recNo. There is also a boolean method isLocked(recNo) which determines whether the current thread has the lock or not.

If the whole lock method is synchronized then there is no need for the boolean method.

If anyone would clarify this it would be of great help.


Regards,

VJ
 
Daniel Dalton
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried searching this forum for "locking" - there are hundreds of posts you could read. Here's a fairly recent one for starters:

http://www.coderanch.com/t/187201/java-developer-SCJD/certification/Locking

Just synchronising the lock method is probably not enough - think about what that would achieve.

You'll probably want to have some data structure representing the records in
the database on which to synchronize in some way.

Good luck!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic