package Thread_case4_package; import java.util.ArrayList; import java.util.Collections; public class Test { public static void main(String[] args) { /* 方式二: 有一个抽奖池,该奖池中存放了奖励金额,该抽奖池中的奖项为{10,5,20,50,100,200,500,800,2,80,300,700}; 创建两个抽奖箱(线程)设置线程名称分别为"抽奖箱1","抽奖箱2" 随机从抽奖池中获取奖项元素并打印在控制台上 打印每个奖箱的最高奖项,总金额 */ //创建奖池 ArrayList list = new ArrayList<>(); Collections.addAll(list, 10, 5, 20, 50, 100, 200, 500, 800, 2, 80, 300, 700); //创建线程 MyThread t1 = new MyThread(list); MyThread t2 = new MyThread(list); MyThread t3 = new MyThread(list); MyThread t4 = new MyThread(list); //设置名字 t1.setName("抽奖箱1"); t2.setName("抽奖箱2"); t3.setName("抽奖箱3"); t4.setName("抽奖箱4"); //启动线程 t1.start(); t2.start(); t3.start(); t4.start(); } }