Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference in Synchronize and wait-notify  RSS feed

 
Vishnu Sharma
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Henry Wong
author
Sheriff
Posts: 22866
119
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Vishnu Sharma
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!