running loop for 5 minutes

前端 未结 3 1965
醉酒成梦
醉酒成梦 2021-01-14 22:10

I have a requirment to run a while loop the 5 min. I looked for the timer api but I could not found to do this. Can any one provide a code snipet for this.
Thanks

3条回答
  •  温柔的废话
    2021-01-14 23:00

    Because you are talking about the timer API I guess what you are after is a delay instead of a "loop running for 5min". If this is the case you could use something like Thread.sleep(..) which would allow to let the CPU do more usefull stuff that busy-waiting. Or at least save some energy and the planet.

提交回复
热议问题