Java チュートリアルには、保護されたブロックを使用したプロデューサー/コンシューマー アプリケーションの基本的な例が含まれています。また、notify と notifyAll の違いと一般的な使用例についても簡単に説明します。
サンプルコードに関する私の質問:
put メソッドと take メソッドのコードを変更することはできますか
//Notify producer that status has changed.
notifyAll();
と
//Notify consumer that status has changed.
notifyAll();
notifyAll() の代わりに notify() を使用しても、Producer-Consumer パターンを正しく実装するには?