Re: Vector#toArray()




"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.

>
> You can get more explicit control over synchronization by
> using ArrayList instead of Vector, but you still need to
> make sure that everything that needs synchronization gets it.
>
> A single structure that is a bottleneck is bad news for
> parallelism. Can you split your data up, and have threads
> specialize in data slices?

This is what I am trying to do :o)
Allan


.