FileDocCategorySizeDatePackage
StringCounterR.javaAPI DocExample581Mon Mar 02 22:04:22 GMT 1998None

StringCounterR.java

// File:  StringCounterR.java
// T Balls
// March 1998
// Output a string 5 times
// Thread created from Runnable


public class StringCounterR implements Runnable
{  public StringCounterR( String s )
   {  str = s;
      t = new Thread( this );
      t.start();
   }

   Thread t;
   
   private String str;
   
   public void run()
   {  for( int i = 1; i <= 5; i++ )
      {  System.out.println( "" + i + "\t" + str );
         t.yield();
      }
   }

   public static void main( String[] args )
   {  new StringCounterR( "Fred" );
      new StringCounterR( "Alice" );
   }
}