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

Class lock vs Object lock  RSS feed

 
Amirtharaj Chinnaraj
Ranch Hand
Posts: 242
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys

i need to know the difference between class level lock and Object level lock

i know that the Object level lock can be achieved by synchronized blocks
if i need no other threads to acess the object.

but what is the necessary of Class level lock.and what conditions i have to think
about Class lock

thanks
amir
 
Muhammad Khojaye
Ranch Hand
Posts: 449
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the necessary of Class level lock.and what conditions i have to think
about Class lock

see this

Hope it helps
 
Arunan Ramanathan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//
but what is the necessary of Class level lock.and what conditions i have to think
about Class lock
//

A static method can't be invoked by an object.A static method can be invoked by calling the class name.
So if we call a synchronized static method then it'll acquire the lock of the class.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!