I make Java applications. It became necessary, under certain conditions, to pause program execution for a long time (an hour or even more). The code is executed in a separate thread.
How correctly will it be used for such a long pause
Thread.sleep(*очень большое число*) Maybe there is another, more correct way?
InterruptedExceptionmay occur. Maybe it's better to use something likeTimer,TimerTask? - Vladyslav Matviienkotimerstarts a separate thread after some time, but does not pause the program. To pause the main thread will come up with a way to synchronize it with the timer. It will be harder tosleep- Sergeygotois not a mortal sin. In addition, in the secondary thread - usesleepas much as fit. But if you want to use it in the main thing - this is wrong, disgusting and terrible by definition. - Vladyslav Matviienko