jQuery in Action, 2nd edition
The moose likes Threads and Synchronization and the fly likes How is locking perfomed Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "How is locking perfomed" Watch "How is locking perfomed" New topic
Author

How is locking perfomed

Kalyan Anand
Ranch Hand

Joined: Feb 07, 2007
Posts: 194
In this case how the JVM performs lock.

1. When the first synchronzied method is entered, on which objects it holds the lock. Only "this" or "this" as well as "super" ?
2. When the super class method is executed, on which object the lock is held ?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16680
    
  19

1. When the first synchronzied method is entered, on which objects it holds the lock. Only "this" or "this" as well as "super" ?


There is no such a thing as a "super" object. The super keyword is used to access the parts of the "this" object that is inherited from the super type. An instance is only one object.

2. When the super class method is executed, on which object the lock is held ?


In the example you provided, it is the "this" object. But as already mentioned, there is no such a thing as a "super" object.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Kalyan Anand
Ranch Hand

Joined: Feb 07, 2007
Posts: 194
Thanks Henry. I get it.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How is locking perfomed
 
Similar Threads
can we Do Calss Level Locking
Synchronized code section causes Tomcat to hang on shutdown
Overloaded Methods in Java are early binded or late binded
Threads
Generic declarations "? super" Vs. "? extends"