本帖最后由 adadadadadadadc 于 2014-11-07 09:28:36 编辑

解决方案 »

  1.   

    idsTemp.加static synchronized(最好这个也加上)
      

  2.   

    在你这个 代码中system.out.print(); 是个同步的方法、 所以是同步的、  
      

  3.   

    Thread.sleep(); 是模拟处理业务的时间的
    正常是不会有问题啦,只有当sleep时间相同,两个线程同时在跑时才有这个问题,虽然概率很小少贴了一个变量声明private static Map<String, String> idsTemp = new HashMap<String, String>();
      

  4.   

     解决了,在run方法里面加上synchronized(idsTemp) {}就好了