Like in Singapore there is law which clearly mentions that in one apartment there cannot be all people belonging to same race/religion.
There has to be mix races.
Even law is in force for re-sale of flat not limited to first time selling.
This type of law can curb problem reported.
I am not sure it will solve completely but surely reduce a lot.
Even in Singapore there was lot of Public anger on this law but Government explain peacefully pros and cons of this. People were angry because they cannot sell. But Pros were good and greater than cons as there wonn't Racial/Religious clashes as children of all racial mix in one apartment and so will elders later and create harmonius climate.
Basically people from any race/religion are good but problem starts with Politics and end to common man.