FileDocCategorySizeDatePackage
RandomGenerator.javaAPI DocExample970Sun Feb 13 16:32:42 GMT 2000None

RandomGenerator

public class RandomGenerator extends Observable implements Runnable

Fields Summary
private int
limit
private Thread
me
private Random
rand
Constructors Summary
public RandomGenerator(int upperLimit)

  limit = upperLimit; 
      me = new Thread( this );
      me.start();
   
Methods Summary
public voidrun()

  
     
     while( true )
      {  DataBlock data = new DataBlock( rand.nextInt( limit+1 ),
                                         rand.nextInt( limit+1 ),
                                         rand.nextInt( limit+1 ),
                                         rand.nextInt( limit+1 ) );
         setChanged();
         notifyObservers( data );
         try
         {  me.sleep( 100 ); // delay to allow AWT thread to update screen
         }
         catch( InterruptedException e )
         {}
      }