• 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:

Wait and notify

 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of those options would be your first guess, and why? The key here is that "notify was used". What does notify do?
reply
    Bookmark Topic Watch Topic
  • New Topic