Home > Back-end >  If judgment in the infinite loop,
If judgment in the infinite loop,

Time:09-28



In infinite loop if judgment, how to make "I is not equal to zero" this sentence is not usurp the screen
(below is just a simple case)

While (1) {
If (I==0) {
Printf (" I is equal to 0 ")

} the else
{printf (" I is not equal to 0 ")}


}

CodePudding user response:

That is not to print, or across a period of time (or count) and print
For example,
Long t1=System. CurrentTimeMillis ();
While (1) {
If (I==0) {
Printf (" I is equal to 0 ")

} the else
{
Long t2=System. CurrentTimeMillis ();
If (t2 - t1 & gt; 5 * 1000) {//every 5 seconds and then print
Printf (" I is not equal to 0 ");
T1=t2;
}
}