The answer you are seeking is perfectly explained in this blog post.
If you read through it you will see that a race condition can among other things corrupt the pointers between items in a bucket, thus causing a lookup to turn into an infinite traversal between two items.
I am not exactly sure how much the implementation of HashMap
has changed for Java 8, but I suspect that the basics still apply.
I should also add that this problem is not too difficult to encounter, I have actually seen it happen in a real life production system!