[
https://issues.apache.org/jira/browse/TUSCANY-2170?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12584098#action_12584098
]
Ramkumar Ramalingam commented on TUSCANY-2170:
----------------------------------------------
Learnt that using Vectors OR Collections.synchronizedList synchronizes your
list object. However, the iterators implemented in the java.util Collections
classes are fail-fast, which means that if one thread changes a collection
while another thread is traversing it through an Iterator, the next
Iterator.hasNext() or Iterator.next() call will throw
ConcurrentModificationException. If we have to prevent
ConcurrentModificationException, we must lock the entire List while you are
iterating by wrapping it with a synchronized block, which inturn is costly.
As a solution to the above problem, the CopyOnWriteArrayList class from
util.concurrent (which will also appear in the java.util.concurrent package in
JDK 1.5) is a thread-safe implementation of ArrayList that offers far better
concurrency. Multiple reads can almost always execute concurrently,
simultaneous reads and writes can usually execute concurrently, and multiple
simultaneous writes can often execute concurrently. Also CopyOnWriteArrayList
contains a mutable reference to an immutable array, so as long as that
reference is held fixed, you get all the thread-safety benefits of immutability
without the need for locking.
Hence i believe the best solution would be to go with CopyOnWriteArrayList
instead of the current ArrayList used to store the list of policy sets,
intents, binding types etc.
Please suggest me if this one is the right approach. Thanks.
> Synchronizing the access to SCADefinitions
> ------------------------------------------
>
> Key: TUSCANY-2170
> URL: https://issues.apache.org/jira/browse/TUSCANY-2170
> Project: Tuscany
> Issue Type: Bug
> Components: Java SCA Core Runtime
> Affects Versions: Java-SCA-Next
> Environment: SVN revision 642920 - Windows
> Reporter: Ramkumar Ramalingam
> Priority: Minor
> Fix For: Java-SCA-Next
>
>
> http://www.mail-archive.com/tuscany-dev%40ws.apache.org/msg29138.html
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]