• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Difference in Synchronize and wait-notify

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 23959
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic