T
Tobi Krausl
Hi!
I need a java-implementation of a queue and found out that
java.util.LinkedList is suitable. In my program there are several
threds accessing and maniplating that LinkedList. Consequently I've to
synchronize access to it.
I found the follwing which doesn't work:
http://javaalmanac.com/egs/java.util/coll_Queue.html?l=rel
e342. Implementing a Queue
LinkedList queue = new LinkedList();
queue.add(object);
Object o = queue.removeFirst();
//Here I get a class-cast-exception, why??????
queue = (LinkedList)Collections.synchronizedList(queue);
I always get a class-cast-exception!
What's wrong??
Tnx,
Tobi
I need a java-implementation of a queue and found out that
java.util.LinkedList is suitable. In my program there are several
threds accessing and maniplating that LinkedList. Consequently I've to
synchronize access to it.
I found the follwing which doesn't work:
http://javaalmanac.com/egs/java.util/coll_Queue.html?l=rel
e342. Implementing a Queue
LinkedList queue = new LinkedList();
queue.add(object);
Object o = queue.removeFirst();
//Here I get a class-cast-exception, why??????
queue = (LinkedList)Collections.synchronizedList(queue);
I always get a class-cast-exception!
What's wrong??
Tnx,
Tobi