Re: Vector#toArray()
- From: Patricia Shanahan <pats@xxxxxxx>
- Date: Mon, 30 May 2005 14:59:42 GMT
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.
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
.
Relevant Pages
- Re: Vector#toArray()
... > Allan Bruce wrote: ... >> running on a parallel machine but it is not any faster. ... > Vector's toArray method is synchronized, ... > make sure that everything that needs synchronization gets it. ... (comp.lang.java.help) - Re: Writing a unittest against thread (un)safe ref-counter pointer
... frustrations before the bug was discovered. ... If your memory is clean afterwards and the program did not crash it is likely that your reference counter is clean. ... I have not found anything better than experience and much care for now to avoid synchronization issues in core libraries of mutli-threaded applications. ... (comp.programming.threads) - Re: Vector#toArray()
... running on a parallel machine but it is not any ... synchronized so I am looking to avoid this. ... The toArray method would get very confused if the Vector were to change while it is running. ... they occur in a synchronized context. ... (comp.lang.java.help) - Re: Why arent long & doubles atomic?
... Reads and writes are atomic for reference variables and for most primitive ... and it's possible to read a partly-instantiated object. ... Unless you know exactly what you're doing and why, DO NOT TRY TO AVOID ... SYNCHRONIZATION. ... (comp.lang.java.programmer) - Re: Thread synchronization
... this can play havoc with its internal synchronization logic. ... However, rather than depend upon convention and good manners to avoid this, ... > carry the conceptual load. ... (comp.lang.java.programmer) |
|