SimpleThread.java




public class SimpleThread extends JApplet {
  JTextArea  Xout  = new JTextArea(10, 30);
  private static int threadCount = 0;

  public void init() {
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    cp.add(new JLabel("SimpleThraed"));
    cp.add(new JScrollPane(Xout));
    for(int i = 0; i < 5; i++)
          new XSimpleThread().start();
    Xout.append("All Threads Started\n");
 }

 class XSimpleThread extends Thread {
  private int countDown = 50;
  private int threadNumber = ++threadCount;
  public XSimpleThread() {
    Xout.append("Making " + threadNumber + "\n");
  }
  public void run() {
    while(true) {
      Xout.append("Thread " +
        threadNumber + "(" + countDown + ")\n");
      if(--countDown == 0) return;
    }
  }
 }
 public static void main(String[] args) {
        Console.run(new SimpleThread(), 400, 250);
 }

} ///:~