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

Deadlock?

 
Shivani Chandna
Ranch Hand
Posts: 380
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in JLS: It states .... This example would deadlock if a single thread were not permitted to lock a lock more than once.
My question is: When would a single thread NOT BE permitted to lock a lock more than once?? Is there some way to do that in Java??



Thanks,
Shivani
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you paraphrasing? I have no idea what part of the JLS you are referencing.
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This seems to be from JLS 14.19.

[Shivani]: My question is: When would a single thread NOT BE permitted to lock a lock more than once?? Is there some way to do that in Java??

No, there's no way to do this in Java. The JLS was explaining why the decision was made to allow a single thread to hold a lock more than once: in order to avoid automatic deadlock in code such as that quoted above.
[ September 04, 2005: Message edited by: Jim Yingst ]
 
Shivani Chandna
Ranch Hand
Posts: 380
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jim Yingst:
This seems to be from JLS 14.19.


Thanks a lot Jim for the answer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic