wood burning stoves
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
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: 24199

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]
I agree. Here's the link: http://aspose.com/file-tools
subject: synchronized
It's not a secret anymore!