Java Concurrency Interview: Implement Producer Consumer pattern using wait-notify
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 - https://youtu.be/6Oo-9Can3H8
Introduction to CompletableFuture - https://youtu.be/ImtZgX1nmr8
Understand how ForkJoinPool works - https://youtu.be/5wgZYyvIVJk
Java Memory Model in 10 minutes - https://youtu.be/Z4hMFBvCDV4
Volatile vs Atomic - https://youtu.be/WH5UvQJizH0
What is Spring Webflux - https://youtu.be/M3jNn3HMeWg
Видео Java Concurrency Interview: Implement Producer Consumer pattern using wait-notify канала Defog Tech
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 - https://youtu.be/6Oo-9Can3H8
Introduction to CompletableFuture - https://youtu.be/ImtZgX1nmr8
Understand how ForkJoinPool works - https://youtu.be/5wgZYyvIVJk
Java Memory Model in 10 minutes - https://youtu.be/Z4hMFBvCDV4
Volatile vs Atomic - https://youtu.be/WH5UvQJizH0
What is Spring Webflux - https://youtu.be/M3jNn3HMeWg
Видео Java Concurrency Interview: Implement Producer Consumer pattern using wait-notify канала Defog Tech
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
Java ReentrantLock - fairness, tryLock and moreJava Concurrency Interview: Implement Scatter Gather pattern13.8 Multithreading InterThread Communication | Producer ConsumerRace Condition vs Data Races in JavaProducer - Consumer Problem in Multi-ThreadingJava Memory Model in 10 minutesThreadLocal in JavaTop 25 Microservice Interview Questions Answered - Java BrainsJava Multithreading Interview QuestionsJava Concurrency Interview - What is an Ideal Threadpool size?How detect and resolve DeadLocks in JavaUsing volatile vs AtomicInteger in Java concurrencyJava 8 Streams APIWhat are Java interrupts?Choose the best Garbage Collector in JavaAdder and Accumulator classes in Java 8Phaser vs CountDownLatch vs CyclicBarrierIntroduction to CompletableFuture in Java 8What is Spring Webflux and when to use it?