Good afternoon, there is a cycle:
while('условие') { // код } A new iteration of the loop is required to occur one second after it starts.
Thread.Sleep(1000); does not fit, because he will fall asleep for a second already after the end of the cycle, and the time will be 1000 + the cycle time
gototo the beginning of the cycle. - Anatol