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

📄 communicator.java

📁 Nachos 5 java version
💻 JAVA
字号:
package nachos.threads;import nachos.machine.*;/** * A <i>communicator</i> allows threads to synchronously exchange 32-bit * messages. Multiple threads can be waiting to <i>speak</i>, * and multiple threads can be waiting to <i>listen</i>. But there should never * be a time when both a speaker and a listener are waiting, because the two * threads can be paired off at this point. */public class Communicator {    /**     * Allocate a new communicator.     */    public Communicator() {    }    /**     * Wait for a thread to listen through this communicator, and then transfer     * <i>word</i> to the listener.     *     * <p>     * Does not return until this thread is paired up with a listening thread.     * Exactly one listener should receive <i>word</i>.     *     * @param	word	the integer to transfer.     */    public void speak(int word) {    }    /**     * Wait for a thread to speak through this communicator, and then return     * the <i>word</i> that thread passed to <tt>speak()</tt>.     *     * @return	the integer transferred.     */        public int listen() {	return 0;    }}

⌨️ 快捷键说明

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