• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java class 'Object' lock.  RSS feed

 
vikram Kesav
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,

Object is the super class of all java classes. When do we talk about synchronization, we use to talk about lock on object. What is this lock means, is it any variable or property of JVM.

Please help me!!!

Thanks in advance.
 
Venkata Kumar
Ranch Hand
Posts: 110
Firefox Browser Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A method which is declared with synchronized keyword can't be accessed by multiple threads concurrently.
The thread acquires a lock on the object, which has the synchronized method, before executing the body of method and releases the lock after completing the execution of method. Every object and class has some data associated with it called as monitor lock. This is similar to semaphore. A class's lock is acquired on the class's Class object.

see this link http://java.sun.com/docs/books/tutorial/essential/concurrency/locksync.html

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!