class ThreadTest1 {
	public static void main(String [] args) {
		PingPong  ping = new PingPong("PING",2);
		PingPong  pong = new PingPong("pong",4);
		ping.start();
		pong.start();
		for(int i=0;i<400;i++)
			System.out.print(i + " ");
		ping.stop();
		pong.stop();
		}
	}

class PingPong extends Thread {
	String word;		// λέξη για εκτύπωση
	int delay;			// χρόνος ανάπαυλας

	PingPong(String wordToPrint, int pauseTime){
		word = wordToPrint;
		delay = pauseTime;
		}

	public void run() {
		try {
			for(int i=0;;i++){
				System.out.print(word +"-" + i + " ");
				sleep(delay);
				}
			}
		catch (InterruptedException e){
			return;	// τερματισμός του thread
			}
		}
	}
