If you refer jdk 8 it will show threshold like
source code [ github jdk 8 ] : https://github.com/openjdk/jdk8/blob/master/jdk/src/share/classes/java/util/IdentityHashMap.java#L276
but after jdk 8 from jdk 9 to current jdk version if found that the threshold is calculated by
2 * size >= table.length
source code [ github jdk 9 ] :
source code [ github jdk current ] :
JDK 8 :
private void init(int initCapacity) {
// assert (initCapacity & -initCapacity) == initCapacity; // power of 2
// assert initCapacity >= MINIMUM_CAPACITY;
// assert initCapacity <= MAXIMUM_CAPACITY;
threshold = (initCapacity * 2)/3;
table = new Object[2 * initCapacity];
}
JDK 9 :
in put method ;
private void init(int initCapacity) {
// assert (initCapacity & -initCapacity) == initCapacity; // power of 2
// assert initCapacity >= MINIMUM_CAPACITY;
// assert initCapacity <= MAXIMUM_CAPACITY;
table = new Object[2 * initCapacity];
}
// Use optimized form of 3 * s.
// Next capacity is len, 2 * current capacity.
if (s + (s << 1) > len && resize(len))