多线程并发调用多个同一个实例多个带锁的方法,导致死锁~
由于很多时候没有注意到,导致一个service的实现里面的2个方法都加了同一个锁,导致当一个方法繁忙的时候另一个锁的方法死锁,执行不了~~
解决方法,最好就是把执行次数多的方法另外加锁,不要和其他带锁的方法用同一个锁即可:
byte[] lock01 = new byte[0];public Result synResultByCache(String fid) {synchronized(lock01){Result result = null;if(objectCache.getObjectCache(DFSFile_List_Key+fid)==null){result = synResultById(fid);if(result!=null)objectCache.putObjectInCache(DFSFile_List_Key+fid, result);}else{result = (Result)objectCache.getObjectCache(DFSFile_List_Key+fid);}return result;}}?