File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes synchronized Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "synchronized" Watch "synchronized" New topic


Chinmay Bajikar
Ranch Hand

Joined: Dec 08, 2001
Posts: 159
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.

The strength of the Wolf is the pack & the strength of the pack is the wolf....Rudyard Kipling
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

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.

[Jess in Action][AskingGoodQuestions]
jQuery in Action, 3rd edition
subject: synchronized
It's not a secret anymore!