Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How is locking perfomed  RSS feed

 
Kalyan Anand
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Kalyan Anand
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Henry. I get it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!