- Aug 3, 2001
- 1,921
- 0
- 76
At one point in my program, it waits for the user to press a button. At this point, my code is:
do{
Thread.sleep(200);
}while (x <-2);
x is changed to > -2 when one of the buttons is pressed. The Thread.sleep(200) is to keep processor usage from going to 100%.
It works, but it seems like a stupid way to do it. What's the usual way to have my program sit patiently until the user presses a button?
Thanks.
do{
Thread.sleep(200);
}while (x <-2);
x is changed to > -2 when one of the buttons is pressed. The Thread.sleep(200) is to keep processor usage from going to 100%.
It works, but it seems like a stupid way to do it. What's the usual way to have my program sit patiently until the user presses a button?
Thanks.