public static void main(String[] args) throws InterruptedException { ThreadGroup group = new ThreadGroup("testgroup"); ArrayListInThread t = new ArrayListInThread(); for (int i = 0; i < 10000; i++) { Thread th = new Thread(group, t, String.valueOf(i)); th.start(); }
while (group.activeCount() > 0) { Thread.sleep(10); } System.out.println(); System.out.println(t.list1.size()); // it should be 10000 if thread safe collection is used. } }