• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Locking question

 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Part of the requirement of my assignment:
When a thread tries to lock a record and that record is already locked,the thread should give up the cpu and consume no more cpu cycles until the lock is available.I am still not experianced in thread programming in Java.
Any idea on how to implement this functionality??
 
Oricio Ocle
Ranch Hand
Posts: 284
Debian Firefox Browser Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Khaled,.
When a thread tries to lock a record and that record is already locked,the thread should give up the cpu and consume no more cpu cycles until the lock is available...

IMO speaking about cpu cycles at such high programming level is cleary an ambiguous requirement Sun want us to face to.
VM provides such hardware isolation that the requirement has no sense.
I decided to interpret it as:
When a thread tries to lock a record and that record is already locked, the thread should enter in a wait state and should not be notified until the lock is available.

Regards, Ori
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic