1 Reply Latest reply on Sep 16, 2010 8:06 PM by 843793

    ConcurrentSkipListMap concurrency question

      I am not much familiar with the internals of that class...

      Is it thread-safe to add entries to that map and in another thread to clone the map ?

      What about the ConcurrentHashMap ?

        • 1. Re: ConcurrentSkipListMap concurrency question
          yes. You will get a consistent copy of the data.
          However if you add multiple entries as a group e.g. with addAll or putAll, there is no guarentee you will get all or none. You could get some of them but not all.

          Because these classes are concurrent, you may find you don't need to clone them. If you want to snapshot of the data, you are unlikely to need to update the snapshot in a multi-threaded manner so you can just copy the data to a plain TreeMap or HashMap.