静态方法出现线程不安全问题
如下程序 
 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后,就不会再出现了.很是奇怪. 
 求高人指点一下其中原因...
------解决方案--------------------在方法声明的时候加上synchronized不知道行不行哦
------解决方案--------------------你这个程序太有问题.company.getName()为null的情况完全取决于stringMap的key值是什么.和多线程没有任务关系.
------解决方案--------------------同步住stringMap就可以了,它和company没有关系 
------解决方案--------------------线程不安全就用线程锁,如果怕影响性能再加个if与线程锁的双锁。