Re: Vector#toArray()



Allan Bruce wrote:

"Patricia Shanahan" <pats@xxxxxxx> wrote in message news:yTFme.2473$s64.1759@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


Allan Bruce wrote:


I am trying to code my application to benefit from running on a parallel machine but it is not any
faster. I think I have some data which is too
synchronized so I am looking to avoid this. I have a
Vector which stores some data but I use toArray() to
get the data as an Object []. I am pretty sure that
this will now be non-synchronized but I thought I
would ask to check - is it?


Thanks. Allan



Vector's toArray method is synchronized, and needs to be synchronized. The toArray method would get very confused if the Vector were to change while it is running.


Yes, I meant: Is access to the array after this call
synchronized? I doubt it but thought I would check.

Accesses to the array will be synchronized if, and only if, they occur in a synchronized context.

Patricia

.