This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

synchronized  RSS feed

 
Chinmay Bajikar
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Would I have a class level lock if I write a synchronized block for a static member of the class rather than an object level lock that I would get when I put "synchronized" in the method signature.
Thanks,
Chinmay
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. In Java, for every loaded class in the JVM, there's an instance of java.lang.Class that represents that class. Synchronized static methods use the class's java.lang.Class object as a lock.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!