Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Priority Blocking Queue ... Is it a Bug??

807606May 21 2007 — edited May 22 2007
Sorry for posting code. I have my reputition of explaing things in wrong way. So consider me. Any way I am getting ClassCastException when i am trying to run this Could any one alter this and post back so that it wont give any exceptions

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.PriorityBlockingQueue;


public class Test {
private BlockingQueue<Inter> bQueue = new PriorityBlockingQueue<Inter>();
public static void main(String args[]) {
Test test = new Test();
test.add(new InterImpl());
test.add(new InterImpl());
test.add(new InterImpl());
test.add(new InterImpl());
test.add(new InterImpl());
test.add(new InterImpl());
}
public void add(Inter inter) {
bQueue.add(inter);
}

}
class InterImpl implements Inter{

public void show() {
System.out.println("Showing InterImpl");

}

}
interface Inter {
public void show();
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 19 2007
Added on May 21 2007
6 comments
188 views