FileDocCategorySizeDatePackage
SinTable.javaAPI DocExample924Thu Apr 22 08:13:24 BST 2004javathreads.examples.ch15.example1

SinTable

public class SinTable extends Object

Fields Summary
private float[]
lookupValues
Constructors Summary
Methods Summary
public synchronized float[]getValues()


        
        if (lookupValues == null) {
            lookupValues = new float [360 * 100];
            for (int i = 0; i < (360*100); i++) {
                float sinValue = (float)Math.sin(
                                    (i % 360)*Math.PI/180.0);
                lookupValues[i] = sinValue * (float)i / 180.0f;
            }    
        }
        return lookupValues;
    
public static voidmain(java.lang.String[] args)

        System.out.println("Starting Example 1 (Control Example)");

        SinTable st = new SinTable();
        float results[] = st.getValues();

        System.out.println("Results: "+ results[0]+ ", "+
                      results[1]+ ", "+ results[2]+ ", "+ "...");
        System.out.println("Done");