I have one custom MyList list that extends ArrayList, for example:
class MyList extends ArrayList<SomeParticularItem>{
[some methods...]
}
Since I have parallel reading and writing to the list, I want to synchronize it:
MyList mylist = (MyList) Collections.synchronizedList(new MyList());
Everything seems to be in order .jar is built. Then at runtime, I get:
java.util.Collections$SynchronizedRandomAccessList cannot be cast to MyList
Is there a better way (if at all) to get a synchronized list of a list that inherits from some java.util.List?
source
share