Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Buggy Lock? Using local Lock Object?  RSS feed

 
Igor Gumski
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this code below Not properly synchronized?

Multiple threads could enter this part of a method... I found this. It seems to me that the LOCK is local thus if a thread tried to lock on it, it'd never be locked because each thread would have its own local LOCK! Am I correct?

if(cacheSuccessful && tempMap != null && !tempMap.isEmpty())
{
final Object LOCK = new Object();
synchronized(LOCK)
{
myCacheMap = tempMap;
}
}
[ April 06, 2006: Message edited by: Igor Gumski ]
 
Edward Harned
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!