Specifications
Sun Services
Java™ Programming Language
Module 13, slide 14 of 37
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Other Ways to Create Threads
1 public class MyThread extends Thread {
2 public void run() {
3 while ( true ) {
4 // do lots of interesting stuff
5 try {
6 Thread.sleep(100);
7 } catch (InterruptedException e) {
8 // sleep interrupted
9 }
10 }
11 }
12
13 public static void main(String args[]) {
14 Thread t = new MyThread();
15 t.start();
16 }
17 }










