Specifications
Sun Services
Java™ Programming Language
Module 13, slide 5 of 37
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Creating the Thread
1 public class ThreadTester {
2 public static void main(String args[]) {
3 HelloRunner r = new HelloRunner();
4 Thread t = new Thread(r);
5 t.start();
6 }
7}
8 class HelloRunner implements Runnable {
9 int i;
10 public void run() {
11 i = 0;
12 while (true) {
13 System.out.println("Hello " + i++);
14 if ( i == 50 ) {
15 break;
16 }
17 }
18 }
19 }










