• Post Reply Bookmark Topic Watch Topic
  • New Topic

Locks in synchronization

 
Shubham Semwal
Ranch Hand
Posts: 176
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I do not understand how the lock is being acquired .
 
Chris Hurst
Ranch Hand
Posts: 443
3
C++ Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The lock is being acquired when either thread enters the synchronized block ???

The confusing thing about this code is that it requires knowledge of java string's and how they are intern'ed , this kind of thing should never appear in real code, you'd be more likely to find it in a java quiz or the like i.e. don't use "a" or any other string literal as your lock.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!