The Artima Developer Community
Sponsored Link

Java Buzz Forum
Difference between wait vs notify vs notifyAll in Java

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Javin Paul

Posts: 1090
Nickname: javinpaul
Registered: Jan, 2012

Javin Paul is Java Programmer working on Finance domain.
Difference between wait vs notify vs notifyAll in Java Posted: Mar 12, 2013 7:12 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Javin Paul.
Original Post: Difference between wait vs notify vs notifyAll in Java
Feed Title: Java67
Feed URL: http://www.java67.com/feeds/posts/default?alt=rss
Feed Description: Java and technology tutorials, tips, questions for all programmers.
Latest Java Buzz Posts
Latest Java Buzz Posts by Javin Paul
Latest Posts From Java67

Advertisement
wait, notify, and notifyAll methods are used for inter thread communication in Java. wait() allows a thread to check for a condition, and wait if condition doesn't met, while notify() and notifyAll() method informs waiting thread for rechecking condition, after changing state of shared variable. One good example of how wait and notify method works is Producer consumer problem, where one thread produces, and wait if bucket is full; and other thread consumes and wait if bucket is empty. Both Producer and Consumer thread, notify each other as well. Producer thread notifies consumer thread after inserting an item in shared queue, while consumer thread notify producer, after consuming item from queue. Though Both notify() and notifyAll()  are used to notify waiting threads, waiting on shared queue object, but there are some subtle difference between notify and notifyAll in Java. Well, when we use notify(), only one of the sleeping thread will get notification, while in case of notifyAll(), all sleeping thread on that object will get notified. This concept confuses many Java programmers, both beginners and experienced alike, Infact this is one of three question which is very popular on wait and notify concept, along with why wait and notify is defined in Object class and why wait and notify called from synchronized method. In this article we will focus on difference between wait, notify, and notifyAll method in Java.
Read more »

Read: Difference between wait vs notify vs notifyAll in Java

Topic: Organizing an Agile Program: Part 2, Networks for Managing Agile Programs Previous Topic   Next Topic Topic: Expressive JAX-RS integration testing with Specs2 and client API 2.0

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use