In the code, the variable timer would specify the duration after which to end the while loop, 60 sec for example.
while(timer) { //run //terminate after 60 sec }
long start = System.currentTimeMillis(); long end = start + 60*1000; // 60 seconds * 1000 ms/sec while (System.currentTimeMillis() < end) { // run }
2.1m questions
2.1m answers
60 comments
57.0k users