⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 drop.java

📁 JAVA 工作指南 可以说是程序员必备的东西哦
💻 JAVA
字号:
public class Drop {    //Message sent from producer to consumer.    private String message;    //True if consumer should wait for producer to send message, false    //if producer should wait for consumer to retrieve message.    private boolean empty = true;    public synchronized String take() {        //Wait until message is available.        while (empty) {            try {                wait();            } catch (InterruptedException e) {}        }        //Toggle status.        empty = true;        //Notify producer that status has changed.        notifyAll();        return message;    }    public synchronized void put(String message) {        //Wait until message has been retrieved.        while (!empty) {            try {                 wait();            } catch (InterruptedException e) {}        }        //Toggle status.        empty = false;        //Store message.        this.message = message;        //Notify consumer that status has changed.        notifyAll();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -