Java Delay/Wait

后端 未结 4 944
悲&欢浪女
悲&欢浪女 2020-12-10 01:20

How do I delay a while loop to 1 second intervals without slowing down the entire code / computer it\'s running on to the one second delay (just the one little loop).

4条回答
  •  悲哀的现实
    2020-12-10 01:43

    As Jigar has indicated you can use another Thread to do work which can operate, sleep etc independently of other Threads. The java.util.Timer class might help you as well since it can perform periodic tasks for you without you having to get into multithreaded programming.

提交回复
热议问题