---------------------------------------------------------------
public class PingPong extends Thread // save as PingPong.java
{
private String word;
private int delay;
public PingPong( String parole, int pendant )
{word = parole; delay = pendant; }
public void run()
{ try { for (;;)
{ System.out.print(word + " ");
sleep(delay);
}
}
catch(InterruptedException e)
{ return; }
}
}
---------------------------------------------------------------
public class Argue // save as Argue.java
{
public static void main( String [] args )
{
new PingPong( "ping", 333 ).start();
new PingPong( "PONG", 1000 ).start();
}
}
---------------------------------------------------------------