Get rid of the T
in
public <T> void put(T item) throws InterruptedException{
^
If you leave it, you are declaring a different type variable that is shadowing your class' type variable T
. You can bind a different type to this one, so the compiler cannot guarantee that it will be the same as the one bound to the Queue
. You seem to want to use the same type variable as the one the in the class declaration.