This discussion is archived
1 Reply Latest reply: Sep 16, 2010 1:06 PM by 843793 RSS

ConcurrentSkipListMap concurrency question

653909 Newbie
Currently Being Moderated
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 ?

Thanks.
  • 1. Re: ConcurrentSkipListMap concurrency question
    843793 Newbie
    Currently Being Moderated
    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.