Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX(URLyBird):About locking :

 
biang lin
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
// Locks a record so that it can only be updated or deleted by this client.
// Returned value is a cookie that must be used when the record is unlocked,
// updated, or deleted. If the specified record is already locked by a different
// client, the current thread gives up the CPU and consumes no CPU cycles until
// the record is unlocked.

public long lockRecord(long recNo)
throws RecordNotFoundException;
I don't understand these:
"the current thread gives up the CPU and consumes no CPU cycles until the record is unlocked."
if i write something like:
while(...){
wait();
}
can this "give up the CPU"??
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, wait() will give up the CPU until notify() or notifyAll() is called.
 
biang lin
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roger,thanks!
Originally posted by Jim Yingst:
Yes, wait() will give up the CPU until notify() or notifyAll() is called.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic