Welcome to the Ranch!
gayan suranga wrote:Once user click ctrl with some key programe should be terminate....but i want to display this into until user press some key.
Let's break the problem into 2 smaller problems
1) Make the
thread print the value till the user presses a specific key
which means make your code
2) listen to the keyboard and check if the specific key was pressed, if yes, exit
Have you learnt loops? A
while loop is exactly what you need for #1
Recommended reading:
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/while.html
For #2 you can use the Scanner class.
More on it here
https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html
The standard way of terminating the application is via
System#exit(int status);