生成指定范围的随机数
public class GenerateRandomNextInt { public static void main(String[] args) { int leftLimit = 2; int rightLimit = 11; Random random = new Random(); Runnable r = () -> { int generatedInteger = leftLimit + random.nextInt(rightLimit - leftLimit + 1); System.out.println(generatedInteger); }; for (int i = 1; i < 10; i++) { new Thread(r).start(); } } }