| Author |
Difference in Synchronize and wait-notify
|
Vishnu Sharma
Ranch Hand
Joined: Feb 03, 2010
Posts: 55
|
|
|
What is exact difference in between these two approaches?? Synchronize is doing the same thing, it holds the object lock and says to the another thread to wait. When it releases the object lock, it is notifying the other thread, that it can now use the object.
|
Regards,
Vishnu
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16685
|
|
The synchronization mechanism and wait-notify mechanism are not different ways of doing the same thing. In fact, wait-notify depends on synchronization. In "threads speak", the first is an implementation of a mutex, and the second is a implementation of a condition variable.
The Sun tutorial on threads is a good start to learn the topic.
http://java.sun.com/docs/books/tutorial/essential/concurrency/
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Vishnu Sharma
Ranch Hand
Joined: Feb 03, 2010
Posts: 55
|
|
Henry Wong wrote:
The synchronization mechanism and wait-notify mechanism are not different ways of doing the same thing. In fact, wait-notify depends on synchronization. In "threads speak", the first is an implementation of a mutex, and the second is a implementation of a condition variable.
The Sun tutorial on threads is a good start to learn the topic.
http://java.sun.com/docs/books/tutorial/essential/concurrency/
Henry
Thanks Henry.
|
 |
 |
|
|
subject: Difference in Synchronize and wait-notify
|
|
|