- import java.util.Random;
- import java.util.Timer;
- import java.util.TimerTask;
- /**
- * Java如何每5秒生成一个随机数
- *
- * @author Java人(java2000.net)
- */
- public class Test {
- public static void main(String[] args) {
- final Random random = new Random();
- Timer executeSchedule = new Timer();
- executeSchedule.schedule(new TimerTask() {
- @Override
- public void run() {
- System.out.println(random.nextInt());
- }
- }, 0, 5000);
- }
- }
Java如何每5秒生成一个随机数
最新推荐文章于 2022-05-22 15:59:04 发布