void () { while (true) { //noinspection unchecked MyReference<K,V> ref = (MyReference<K,V>)myQueue.poll(); if (ref == null) { return; } K key = ref.getKey(); if (myMap.get(key) == ref) { myMap.remove(key); } } }