2 Replies Latest reply on Sep 13, 2012 4:25 PM by clebert.suconic

    ConcurrentHashSet vs newSetFromMap

    nimo22

      What is the difference of using this:

       

      org.hornetq.utils.ConcurrentHashSet

       

      {code}

      private Set<Object> threadSafe= new ConcurrentHashSet<Object>();

      {code}

      and this:

       

      java.util.Collections.newSetFromMap

       

      {code}

      private Set<Object> threadSafe=  Collections.newSetFromMap(new ConcurrentHashMap<Object, Boolean>());

      {code}

        • 1. Re: ConcurrentHashSet vs newSetFromMap
          clebert.suconic

          It would be the same...

           

           

          The code exists since we were on JVM 1.4.

           

          On 2.2, the code still needs to run in JVM 1.5 at the client.. so I would rather keep the code as it is (it's not a big deal anyways).

          • 2. Re: ConcurrentHashSet vs newSetFromMap
            clebert.suconic

            nimo stephan wrote:

             

            What is the difference of using this:

             

            org.hornetq.utils.ConcurrentHashSet

             

            
            private Set<Object> threadSafe= new ConcurrentHashSet<Object>();
            

             

            and this:

             

            java.util.Collections.newSetFromMap

             

            
            private Set<Object> threadSafe=  Collections.newSetFromMap(new ConcurrentHashMap<Object, Boolean>());
            

             

             

            BTW: thanks for the hint.. it's always nice to learn new tricks! But I don't think we can change it now.