FileDocCategorySizeDatePackage
ObjectCreator.javaAPI DocExample974Thu Nov 08 00:22:36 GMT 2001com.ora.rmibook.chapter12.pool.thread1

ObjectCreator

public class ObjectCreator extends Object implements Runnable

Fields Summary
private ThreadedPool1
_owner
private boolean
_requestPending
Constructors Summary
public ObjectCreator(ThreadedPool1 owner)

        _owner = owner;
    
Methods Summary
public synchronized voidaskForObject()

        _requestPending = true;
        notify();
    
public voidrun()

        boolean needToCreate = false;

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