This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Houston, we have threads...
- From: Adam Megacz <gcj at lists dot megacz dot com>
- To: java at gcc dot gnu dot org
- Date: 12 Dec 2001 14:27:12 -0500
- Subject: Houston, we have threads...
- Organization: Myself
word..
public class hello extends Thread {
public hello() { start(); }
public void run() {
while(true) {
System.out.println("I am " + this);
Thread.yield();
}
}
public static void main(String[] s) {
System.out.println("start");
new hello();
new hello();
new hello();
try { Thread.sleep(10000); } catch (Exception e) { }
System.out.println("done");
}
}
$ ./hello.exe
start
I am Thread[Thread-1,5,main]
I am Thread[Thread-2,5,main]
I am Thread[Thread-3,5,main]
I am Thread[Thread-2,5,main]
I am Thread[Thread-3,5,main]
I am Thread[Thread-1,5,main]
I am Thread[Thread-2,5,main]
I am Thread[Thread-3,5,main]
....