You're right: this code is not thread-safe and depending on the Map implementation and race condition may produce any random effect: correct result, silent loss of data, some exception or endless loop. You may easily check it like this:
int equal = 0; for(int i=0; i<100; i++) { // create test input map like {0 -> 0, 1 -> 1, 2 -> 2, ...} Map<Integer, Integer> input = IntStream.range(0, 200).boxed() .collect(Collectors.toMap(x -> x, x -> x)); Map<Integer, Integer> result = new HashMap<>(); // write it into another HashMap in parallel way without key collisions input.entrySet().parallelStream().unordered() .forEach(entry -> result.put(entry.getKey(), entry.getValue())); if(result.equals(input)) equal++; } System.out.println(equal); On my machine this code usually prints something between 20 and 40 instead of 100. If I change HashMap to TreeMap, it usually fails with NullPointerException or becomes stuck in the infinite loop inside TreeMap implementation.