如下程序
public static Company formatCompany(Map stringMap) throws Exception{
Company company = new Company(); Set keySet = stringMap.keySet(); Iterator it = keySet.iterator(); while(it.hasNext()){ String key = (String)it.next(); if("Company Name:".equals(key)){
String name = getCurrentLengthString((String)stringMap.get(key),150,true,true);
company.setName(name);
}else
if("Website:".equals(key)){
String website = getCurrentLengthString((String)stringMap.get(key),400,true,false);
company.setWebsite(website);
}else{
throw new Exception("property is not mached");
}
} return company;
}
这个方法在多线程环境中被调用,我可以确保company都会被设置Name和webSite,但是我却在程序中得到company.getName = null!当我把线程数改成1后,就不会再出现了.很是奇怪.
求高人指点一下其中原因...