You can make your thread sleep for 30 minutes like this:
Thread.sleep(30 * // minutes to sleep
60 * // seconds to a minute
1000); // milliseconds to a second
Using Thread.sleep
is not inherently bad. Simply explained, it just tells the thread scheduler to preempt the thread. Thread.sleep
is bad when it is incorrectly used.
You could also use, as kozla13 has shown in their comment:
TimeUnit.MINUTES.sleep(30);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…