[concurrency-interest] some stupid questions

Rémi Forax forax at univ-mlv.fr
Wed Dec 19 10:07:06 EST 2007


First a remark,
in the doc of ForkJoinTask, you can see this sentence:
"The ForkJoinTask class is not directly subclassable outside of this 
package"
but the constructor is public ?

Else, why ||*ParallelArray 
<http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/forkjoin/ParallelArray.html#ParallelArray%28jsr166y.forkjoin.ForkJoinExecutor,%20int,%20java.lang.Class%29> 
is not a List,
it provides get/set/size/iterator but if you want a list you need to 
create another object
using asList(). So basically, why he doesn't inherits from AbstractList 
(and implements RandomAccess) ?

I think the same idea can be applied to  *ParallelArray.WithMapping.
By the way why there is no get and set here ?, is it because these 
operations can't be done in constant time ?
Perhaps ParallelArray.WithMapping can inherit from SequentialAbstractList.

*I don't like the fact *|*ParallelArray 
<http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/forkjoin/ParallelArray.html#ParallelArray%28jsr166y.forkjoin.ForkJoinExecutor,%20int,%20T%5B%5D%29>*(ForkJoinExecutor 
<http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/forkjoin/ForkJoinExecutor.html> executor, 
int size, T 
<http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/forkjoin/ParallelArray.html>[] sourceToCopy)| 

perform a defensive copy and |*ParallelArray 
<http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/forkjoin/ParallelArray.html#ParallelArray%28jsr166y.forkjoin.ForkJoinExecutor,%20T%5B%5D%29>*(ForkJoinExecutor 
<http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/forkjoin/ForkJoinExecutor.html> executor, 
T 
<http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/forkjoin/ParallelArray.html>[] handoff)
don't.
|*
Perhaps The constructor
*|*ParallelArray 
<http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/forkjoin/ParallelArray.html#ParallelArray%28jsr166y.forkjoin.ForkJoinExecutor,%20T%5B%5D%29>*(ForkJoinExecutor 
<http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/forkjoin/ForkJoinExecutor.html> executor, 
T 
<http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/forkjoin/ParallelArray.html>[] handoff) 
should be protected
and a static method "wrap" introduced.

|I  think all  replace* method  should be renamed  to  fill*  |like in 
java.util.Arrays.
||And to be consistent, randomFill() should be fillRandom().

I wonder if ||*newArray 
<http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/forkjoin/ParallelArray.WithFilter.html#newArray%28java.lang.Class%29>*(Class 
<http://java.sun.com/javase/6/docs/api/java/lang/Class.html?is-external=true><? 
super T 
<http://gee.cs.oswego.edu/dl/jsr166/dist/jsr166ydocs/jsr166y/forkjoin/ParallelArray.WithFilter.html>> elementType 
can't be rewritten to
<U> ParallelArray<U> newArray(Class<U> elementType) in order to allow 
upcasting
if possible and a ClassCastException otherwise.

cheers,
Rémi



|



More information about the Concurrency-interest mailing list