Difference between monitor and lock
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Blue_Bird
Posted On:   Tuesday, November 3, 2009 12:17 AM

When this.wait() is invoked, the current thread will wait on this object's monitor and release this object's synchronization lock.


So, what is the difference between monitor and lock?

Re: Difference between monitor and lock

Posted By:   Edward_Harned  
Posted On:   Friday, November 13, 2009 10:11 AM

synchronization lock.


Perhaps you're new to programming. You need to read the specifications/documentation with an eye to explicit meaning; not always what seems true.


wait() releases the synchronization lock. This has nothing to do with the Lock class.

Re: Difference between monitor and lock

Posted By:   Edward_Harned  
Posted On:   Saturday, November 7, 2009 11:31 AM

Every object has a built-in monitor. This way you can synchronize on any object. That is, you can create an object in one thread, pass a reference to that object to another thread and both threads can synchronize on the object.


Locks come with the java.util.concurrent.locks package. You need to read the description for that package. (Too much to do here.)

About | Sitemap | Contact