[2175] in java-interest
Re: simple thread examples needed
daemon@ATHENA.MIT.EDU (Arthur van Hoff)
Tue Sep 26 16:29:52 1995
Date: Tue, 26 Sep 1995 09:46:59 -0800 (PDT)
From: Arthur van Hoff <Arthur.Vanhoff@Eng.Sun.COM>
Reply-To: Arthur van Hoff <Arthur.Vanhoff@Eng.Sun.COM>
To: "ADAM HOLT 11 Harold #3 Somerville 617 666-0240 http://web.mit.edu/holt/adam" <holt@MIT.EDU>
Cc: java-interest@java.Eng.Sun.COM
Hi Harold,
> I'm trying to puzzle out threads and could use a nice, simple example.
> anyone have one?
Here my ping pong program:
class PingPong extends Thread {
String arg;
int delay;
PingPong(String arg, int delay) {
this.arg = arg;
this.delay = delay;
start();
}
public void run() {
while (true) {
System.out.println(arg);
try {
sleep(delay);
} catch (InterruptedException e) {
return;
}
}
}
public static void main(String argv[]) {
new PingPong("ping", 300);
new PingPong("pong", 1000);
}
}
> (I am <really> missing searchable email archives - those aren't being
> stored anywhere else now are they? I saw one person offer... )
Check out http://java.sun.com/, there is a link to searchable archives there.
Have fun,
Arthur van Hoff
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com