Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class lock

 
Ambapali Pal
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is class lock?
Do we need to know class lock for scpj 1.4 ?

Thank you,
Ambapali
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea what it is -- and I've read two SCPJ exam books -- so I'm gonna say no -- you don't need to know it (whatever it is)
 
John Paverd
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

When synchMethod2 is called, the JVM will obtain a lock on the object my.
When synchMethod1 is called, the JVM will obtain a lock on the instance of java.lang.Class that represents MyClass, rather than obtaining a lock on a particular instance of MyClass.
For the exam it is probably enough to know that for a particular class, only 1 synchronized static method can be executing at a particular point in time, but many synchronized instance methods can run concurrently, as long as they are associated with different instances of that class.
[ January 13, 2003: Message edited by: John Paverd ]
 
Ambapali Pal
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Jhon.
 
Ambapali Pal
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry. John not Jhon
 
John Paverd
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ambapali Pal:
I am sorry. John not Jhon

Thats quite OK, Amabpali, oops I mean Ambapali

If you click on the little pencil and paper symbol above your post, you can correct it. I know this because I have to use this feature a lot on my own posts. In fact, you can see that I edited my first post in this topic.
You Can Call Me Al! - Paul Simon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic