aspose file tools
The moose likes Threads and Synchronization and the fly likes Wait and notify Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Reply Bookmark "Wait and notify" Watch "Wait and notify" New topic
Author

Wait and notify

Kalyan Anand
Ranch Hand

Joined: Feb 07, 2007
Posts: 194
In the producer consumer problem.. we have multiple producer and multiple consumer threads.. so here is a question

1. Producer fills up the content and raises notify()

2. As notify was used it invoked a Producer thread
3. Producer realizes that the list isNotEmpty and it waits.

At the end of step 3 what would happen ?

a. Neither any Producer nor any Consumer executes and it hangs
b. The JVM invokes some thread again because there is no lock on the object
c. The behavior cannot be predicted and its up to JVM
d. None of the above
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3036
    
    4

Which of those options would be your first guess, and why? The key here is that "notify was used". What does notify do?


Steve
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Wait and notify
 
Similar Threads
wait, notify IllegalMonitorStateException
Process the multiple records in a file by Producer/consumer concept using Multithreading
Thread wait() and notify()
Blocked vs Waiting Thread
Using synchronize on overloaded methods