FileDocCategorySizeDatePackage
CalculatorTest.javaAPI DocExample676Mon Mar 08 22:41:36 GMT 2004javathreads.examples.ch05.example4

CalculatorTest

public class CalculatorTest extends Calculator implements Runnable

Fields Summary
Constructors Summary
Methods Summary
protected java.lang.ObjectdoLocalCalculate(java.lang.Object p)

        System.out.println("Doing calculation of " + p + " in thread " + Thread.currentThread());
        return p;
    
public static voidmain(java.lang.String[] args)

        int nThreads = Integer.parseInt(args[0]);
        for (int i = 0; i < nThreads; i++) {
            Thread t = new Thread(new CalculatorTest());
            t.start();
        }
    
public voidrun()

        for (int i = 0; i < 30; i++) {
            Integer p = new Integer(i % 5);
            calculate(p);
        }