ThreadsStartExample näide

Allikas: Lambda

public class ThreadsStartExample {
  public static void main (String argv[]) {
     new ThreadExample ().start ();
     new Thread(new RunnableExample ()).start ();
 }
}

class ThreadExample extends Thread {
   public void run () {
      for (int i = 1; i <= 100; i++) {
         System.out.println("Thread: " + i);
      }
   }
}

class RunnableExample implements Runnable {
	public void run () {
	  for (int i = 1; i <= 100; i++) {
         	System.out.println ("Runnable: " + i);
      	  }
        }
}