@@ -0,0 +1,2733 @@
+//  Copyright 2016 The Minorminor Open Source Project%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A//     http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A//%0A%0Apackage jdktest;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0Aimport java.util.Collections;%0Aimport java.util.Set;%0Aimport java.util.concurrent.ConcurrentHashMap;%0Aimport java.util.concurrent.CountDownLatch;%0Aimport java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0A%0A// HashSet implementation is not synchronized. If multiple threads access a hash map concurrently, and at least one of the threads%0A// modifies the map structurally, it must be synchronized externally.%0Apublic class HashSetTest %7B%0A    private Set%3CInteger%3E accounts = Collections.newSetFromMap(new ConcurrentHashMap%3CInteger, Boolean%3E(10000));%0A    // Collections.synchronizedSet(new HashSet%3CInteger%3E(10000));%0A%0A    public void addElement(CountDownLatch startRun, CountDownLatch done, int init) %7B%0A        try %7B%0A            startRun.await();%0A        %7D catch (InterruptedException e) %7B%0A            e.printStackTrace();%0A        %7D%0A%0A        for (int i = init; i %3C init + 5000; i++) %7B%0A            // synchronized (accounts) %7B%0A            accounts.add(i);%0A            // %7D%0A        %7D%0A        done.countDown();%0A    %7D%0A%0A    public int test() %7B%0A        final CountDownLatch startRun = new CountDownLatch(1);%0A        final CountDownLatch done = new CountDownLatch(2);%0A        ExecutorService executors = Executors.newFixedThreadPool(2);%0A        executors.submit(new Runnable() %7B%0A            @Override%0A            public void run() %7B%0A                addElement(startRun, done, 0);%0A            %7D%0A        %7D);%0A        executors.submit(new Runnable() %7B%0A            @Override%0A            public void run() %7B%0A                addElement(startRun, done, 5000);%0A            %7D%0A        %7D);%0A%0A        startRun.countDown();%0A%0A        try %7B%0A            done.await();%0A        %7D catch (InterruptedException e) %7B%0A            e.printStackTrace();%0A        %7D%0A%0A        executors.shutdown();%0A        return accounts.size();%0A    %7D%0A%0A    @Test(timeout = 3000L, expected = Test.None.class)%0A    public void testHashSetTest() %7B%0A        int i = 0;%0A        while (i %3C 10) %7B%0A            Assert.assertEquals(new HashSetTest().test(), 10000);%0A            i++;%0A        %7D%0A    %7D%0A%7D%0A

Add HashSetTest.java