this is the code for my class assignment

import java.util.Calendar;

class ClockThread implements Runnable,KeyListner{
	int sec,min,hour;
	Thread thr;
	
	ClockThread(){
		Calendar rightNow = Calendar.getInstance();
		hour=rightNow.get(Calendar.HOUR);
		min=rightNow.get(Calendar.MINUTE);
		sec=rightNow.get(Calendar.SECOND);
		
		thr=new Thread(this);
		thr.start();
	}

	public void run(){
		while(true){
			try{
				Thread.sleep(1000);
				sec++;
			}
			catch(InterruptedException ie){
				System.out.println(ie);
			}
			
			if(sec>=59){
				sec=0;
				min++;
			}
			if(min>=59){
				min=0;
				hour++;
			}
			if(hour>=11){
				hour=0;
			}
			System.out.format("\r%02d:%02d:%02d",hour,min,sec);
	}}

	
	
}

class Clock{
	public static void main(String args[]){
		new ClockThread();
}}

what i want is that instead of while(true) i can put some sorta event handler which breaks in event of a KeyDown.

please help me out here..

i read that post but i am having difficulty implementing it!
i cannt understand how to call the KeyListner,
i want the while loop to break if KeyDown Event occurs..

something of this sense ->

while(!KeyDownEvent()){}

some kinda function that return a boolean..

This question has already been answered. Start a new discussion instead.