//测试juc安全类型的集合 public class TestJUC { public static void main(String[] args) { CopyOnWriteArrayList<String> copyOnWriteArrayList=new CopyOnWriteArrayList<String>(); for (int i = 0; i < 10000; i++) { new Thread(()->{ copyOnWriteArrayList.add(Thread.currentThread().getName()); }).start(); } } }