[2260] in java-interest

home help back first fref pref prev next nref lref last post

Re: simple thread examples needed

daemon@ATHENA.MIT.EDU (Eric Barna)
Wed Sep 27 14:15:29 1995

From: Eric Barna <ebarna@teachersoft.com>
To: "ADAM HOLT 11 Harold #3 Somerville 617 666-0240 http://web.mit.edu/holt/adam" <holt@MIT.EDU>
Date: Tue, 26 Sep 1995 15:58:40 ()
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
..

-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post