Java Concurrency Interview: Implement Producer Consumer pattern using wait-notify

Published: 01 January 1970
on channel: Defog Tech
142,537
3.1k

Implementing Producer Consumer using BlockingQueue, Locks/Conditions and Wait-Notify.

Important: The last part about using wait-notify is incorrect. My mistake, sorry about that.

The object used to wait/notify should be the same object used by threads to synchronize (to avoid IllegalMonitorStateException). So correct code should be similar to:

synchronize(sharedQ){
sharedQ.wait();
}
synchronize(sharedQ){
sharedQ.notifyAll();
}

That was a basic mistake which I should have caught. I feel bad about misleading the initial viewers. Sorry.


Channel
----------------------------------
Master difficult programming concepts in few minutes. I try to explain difficult concepts like Java concurrency in simple to understand manner. Explore videos on topics like Spring Boot, Cloud Foundry, Java 8 and more. I am happy to clarify your doubts. Ask me anything in the comments. Also happy to take requests for new videos.

New video added every Sunday.

Subscribe or explore the channel - http://bit.ly/defog_tech

Current Playlists
----------------------------------
Java Executor Service - http://bit.ly/exec_srvc
Java Concurrency - http://bit.ly/java_crncy
Spring Boot 2.0 - http://bit.ly/spr_boot2
Java 8 - http://bit.ly/java_8-11
Intellij IDEA Shortcuts - http://bit.ly/i_idea

Popular Videos
----------------------------------
Executor Service -    • Java ExecutorService - Part 1 - Intro...  
Introduction to CompletableFuture -    • Introduction to CompletableFuture in ...  
Understand how ForkJoinPool works -    • Understanding how ForkJoinPool works  
Java Memory Model in 10 minutes -    • Java Memory Model in 10 minutes  
Volatile vs Atomic -    • Using volatile vs AtomicInteger in Ja...  
What is Spring Webflux -    • What is Spring Webflux and when to us...  


On this page of the site you can watch the video online Java Concurrency Interview: Implement Producer Consumer pattern using wait-notify with a duration of hours minute second in good quality, which was uploaded by the user Defog Tech 01 January 1970, share the link with friends and acquaintances, this video has already been watched 142,537 times on youtube and it was liked by 3.1 thousand viewers. Enjoy your viewing!