Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>At the risk of stating the obvious (or being plain wrong) isn't the difference that </p> <blockquote> <p>The synchronization wrappers add automatic synchronization (thread-safety) to an arbitrary collection</p> </blockquote> <p><a href="http://docs.oracle.com/javase/tutorial/collections/implementations/wrapper.html" rel="nofollow noreferrer">http://docs.oracle.com/javase/tutorial/collections/implementations/wrapper.html</a> and continues to say </p> <blockquote> <p>A collection created in this fashion is every bit as thread-safe as a normally synchronized collection, such as a Vector.</p> </blockquote> <p>You may like to see this thread for issues regarding HashMaps and concurrency - <a href="https://stackoverflow.com/questions/1003026/hashmap-concurrency-issue">Hashmap concurrency issue</a> (or you are possibly very much aware of them already). A good example is:</p> <blockquote> <p>The conditions you describe will not be satisfied by HashMap. Since the process of updating a map is not atomic you may encounter the map in an invalid state. Multiple writes might leave it in a corrupted state. ConcurrentHashMap (1.5 or later) does what you want.</p> </blockquote> <p><a href="https://stackoverflow.com/a/1003071/201648">https://stackoverflow.com/a/1003071/201648</a></p> <p>I guess in terms of "when should I use this" I would tend to use the syncronised collection where concurrency is required, otherwise you may be creating more work for yourself (see below).</p> <p>In terms of altering the behavior</p> <blockquote> <p>If an explicit iterator is used, the iterator method must be called from within the synchronized block. Failure to follow this advice may result in nondeterministic behavior</p> </blockquote> <p>There are more consequences of using synchronization given at the (Oracle) link provided.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload