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

📄 objectcreator.java

📁 RMI英文教程,从各个方面教你怎么进行RMI开发
💻 JAVA
字号:
package com.ora.rmibook.chapter12.pool.thread1;


import com.ora.rmibook.chapter12.pool.*;


public class ObjectCreator implements Runnable {
    private ThreadedPool1 _owner;
    private boolean _requestPending;
    public ObjectCreator(ThreadedPool1 owner) {
        _owner = owner;
    }

    public void run() {
        boolean needToCreate = false;

        while (true) {
            synchronized (this) {
                while (!_requestPending) {
                    try {
                        wait();
                    } catch (InterruptedException e) {/* ignored */
                    }
                }
                needToCreate = _requestPending;
                _requestPending = false;
            }
            if (needToCreate) {
                _owner.createAndAddObject();
            }
        }
    }

    public synchronized void askForObject() {
        _requestPending = true;
        notify();
    }
}

⌨️ 快捷键说明

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