Thread.currentThread().sleep(3600000); @ResponseBody @RequestMapping("/test") public JsonResult test(){ Thread thread=new Thread(runnable); thread.start(); System.out.println("09+"); return JsonResultUtil.getObjectMessageJson(1,""); } public int randomInt(int from, int to) { Random r = new Random(); return from + r.nextInt(to - from); } private Runnable runnable=new Runnable() { @Override public void run() { String charValue = ""; for (int i = 0; i < 6; i++) { char c = (char) (randomInt(0, 10) + '0'); charValue += String.valueOf(c); } MoblieRandom moblieRandom=new MoblieRandom(); moblieRandom.setRandom(charValue); moblieRandom.setUserid(100); moblieRandom.setMobile(0000000+""); try { Thread.sleep(1000*60*5); mobileRandomManager.creatMobileRandom(moblieRandom); }catch (Exception e){ } } };
多线程实例,6位随机数
最新推荐文章于 2021-04-10 14:49:28 发布