// This code demonstrates the second way to create a thread by implementing the
// interface Runnable. To see how the OS scheduler runs the threads
// run it multiple times and observe the output.

public class ThreadDemo1b
{
  public static void main(String[] args)
  {
    Thread tA = new Thread(new ShowChar2('A'));    // create 3 threads
    Thread tB = new Thread(new ShowChar2('B'));
    Thread tC = new Thread(new ShowChar2('C'));

    tA.start();                         // ... and run 'em
    tB.start();
    tC.start();
  }
}

class ShowChar2 implements Runnable
{
  private char c;
  private int rep = 100;

  public ShowChar2(char c)
  {
    this.c = c;
  }

  public void run()
  {
    for (int i=0; i<rep; i++)            // print REP copies of a character
      System.out.print(c);
  }
}
  
