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

lock method doubts

 
pramod karnani
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In Sun instruction lock method signature is given like this:

// 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;



but it does not say anything about deadlock .

Q. Let say record number is already locked by making this call lock(1) and if second call for same record number happens then what should be expected output ?

In my implementation what i did if lock method is called on already locked record number ,it waits for 5 seconds and comes out from the method .

[b]Logic of waiting 5 sec is okay?


What to do in this condition ( if trying to lock the record that is already locked )?[/b]

Is this deadlock ?

Please let me know .




 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic