Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / May 2005

Tip: Looking for answers? Try searching our database.

Vector#toArray()

Thread view: 
Allan Bruce - 30 May 2005 11:14 GMT
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
Patricia Shanahan - 30 May 2005 15:59 GMT
> I am trying to code my application to benefit from
> running on a parallel machine but it is not any faster.
[quoted text clipped - 6 lines]
>
> 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.

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?

Patricia
Allan Bruce - 31 May 2005 09:54 GMT
>> I am trying to code my application to benefit from
>> running on a parallel machine but it is not any faster.
[quoted text clipped - 10 lines]
> 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
[quoted text clipped - 3 lines]
> parallelism. Can you split your data up, and have threads
> specialize in data slices?

This is what I am trying to do :o)
Allan
Patricia Shanahan - 31 May 2005 11:46 GMT
>>> I am trying to code my application to benefit from
>>> running on a parallel machine but it is not any
[quoted text clipped - 14 lines]
> 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
Allan Bruce - 31 May 2005 13:27 GMT
>>>> I am trying to code my application to benefit from running on a
>>>> parallel machine but it is not any
[quoted text clipped - 19 lines]
>
> Patricia

Thats what I thought, thanks!
Allan


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.