Page 1 of 1

About Question enthuware.ocpjp.v8.2.1707 :

Posted: Mon Jul 04, 2016 4:11 pm
by johnlong
Hi

Answer says : All modification operations of a CopyOnWriteArrayList are considered atomic.
Just to clarify - all modifications ( i.e. add() ) or modifications that write multiple elements (i.e. addAll() ) will be atomic?

Re: About Question enthuware.ocpjp.v8.2.1707 :

Posted: Mon Jul 04, 2016 8:46 pm
by admin
Yes, that is correct.

Re: About Question enthuware.ocpjp.v8.2.1707 :

Posted: Tue Jul 05, 2016 7:41 pm
by johnlong
Sorry, which statement is correct?

a) all modifications ( i.e. add() )
or
b) modifications that write multiple elements (i.e. addAll() )

I believe it is option b only.

Re: About Question enthuware.ocpjp.v8.2.1707 :

Posted: Wed Jul 06, 2016 12:05 am
by admin
Well, all modifications include all modifications even though it doesn't make much sense for a single modification. A single modification is, nevertheless, atomic.

Re: About Question enthuware.ocpjp.v8.2.1707 :

Posted: Wed Jul 06, 2016 5:27 pm
by johnlong
But batch of single modifications run from one method would not block, correct?

Re: About Question enthuware.ocpjp.v8.2.1707 :

Posted: Wed Jul 06, 2016 6:33 pm
by admin
Not sure what you mean. Please post code.