Reputation: 379
I have a piece of code that builds up an ArrayList of a custom class type as an ouput of a function. Then, I attempt to addall(Collection) this ArrayList to a ConcurrentLinkedDeque. What seems to happen is that the ConcurrentLinkedDeque ends up containing ArrayList.size() of the last element in the ArrayList.
I have done various checks to see if the ArrayList is built properly and including proper elements, but do not seem to see through this problem. Are there any peculiarities with adding Collections to ConcurrentLinkedDeque's?
Upvotes: 1
Views: 180
Reputation: 379
It seems to work now. I found a bug involving memory allocation.
addall(Collection) works for ConcurrentLinkedDeque.
Upvotes: 0
Reputation: 289
Can you try something like this
public class ConcurrentLDTrial{
public static void main(String[] args) {
List<Integer> a = new ArrayList<Integer>();
a.add(2);
a.add(3);
ConcurrentLinkedDeque<Integer> cd = new ConcurrentLinkedDeque<Integer>(a);
System.out.println(cd);
}
}
The output I get for this is [2, 3] , which is expected.
Cast the data structures appropriately to your custom class.
Upvotes: 1