FileDocCategorySizeDatePackage
Supplier.javaAPI DocExample1557Thu May 23 09:32:50 BST 2002 sample.openmbean

Supplier

public class Supplier extends Worker
put your documentation comment here

Fields Summary
public static final String
ROLE
private static final int
DEFAULT_WORK_FACTOR
Constructors Summary
public Supplier(Queue queue)
put your documentation comment here

param
Queue queue


                   
        
        this(queue, DEFAULT_WORK_FACTOR);
    
public Supplier(Queue queue, int workFactor)
put your documentation comment here

param
Queue queue
param
int workFactor

        super(queue, workFactor);
    
Methods Summary
public voidrun()
put your documentation comment here

        //**********
        // This is where the "work" takes place. In a real-world
        /// application that uses this pattern, this logic would
        /// be replaced by the real application logic.
        //**********
        _queue.addSupplier();
        while (!_stopCalled) {
            while (_suspended) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {}
            }
            // Burn some cycles...
            calculatePrimes(_workFactor);
            // Now place a WorkUnit in the Queue
            _queue.add(new WorkUnit());
            _numberOfUnitsProcessed++;
        }
        _queue.removeSupplier();