Java return 与finally
public Map<String, Set<NearFinderData>> getDataMap() { Map<String, Set<NearFinderData>> latestData = null; lock.readLock().lock(); try { latestData = NEAR_FINDER_DATA; } finally { lock.readLock().unlock(); } return latestData; }
和
public Map<String, Set<NearFinderData>> getDataMap() { lock.readLock().lock(); try { return NEAR_FINDER_DATA; } finally { lock.readLock().unlock(); } }
的区别是什么呢?其中NEAR_FINDER_DATA 是一个被修改的Map
java read-write-lock finally lock return
Rainbow
11 years, 4 months ago