I have a class used to generate random values and put these random values into a hashmap. But I have configured the test suite to be able to execute paralley. So, I have declared constroctor as private to be thread-safes this hashmap. Is this mechanism right?. If it is incorrect, how can I achieve it?
public class RandomData{
private static Hashmap map = new Hashmap();
private RandomData(){}
public String getRandomVal(){
/* generate random value and put the map, if this generated
value is not existing in the map, it will return or else
a new value is generated again and return. */
}
}