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

Question about locking

 
HaoZhe Xu
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the assignment introduction, there is a sentence:"Any attempt to lock a resource that is already locked should cause the current thread to give up the CPU, consuming no CPU cycles until the desired resource becomes available. "
Let's say, thread A is doing something with resource 1 (so resource 1 was already locked by thread a), then thread B want to access resource 1, what will happen then? does is mean thread A should give up resource 1 to B or thread b should give up? what does the last sentence mean?
 
Wilder C Rodrigues
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If thread A attemp to access resource that is been used by thread B, so thread A has to wait for thread B release the resource. When thread B release the reasource it calls notify() or notifyAll() and thread A try again to get the resource.
Understand me?
Best,
Wilder C. Rodrigues
SCPJ
SCWCD
JUGLeader
The new Marillion album is coming - Marbles
www.marillion.com
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic