G****3 发帖数: 11 | 1 I have a problem. The entry in a hashmap has a big cost to create. So I want
to do lazy initialization. But it is in multithreaded enviroment. So I
resolve the issues like doubled checked locking and etc. |
w**z 发帖数: 8232 | 2 take a look at guava cache.
want
【在 G****3 的大作中提到】 : I have a problem. The entry in a hashmap has a big cost to create. So I want : to do lazy initialization. But it is in multithreaded enviroment. So I : resolve the issues like doubled checked locking and etc.
|
g*****g 发帖数: 34805 | 3 ConcurrentHashMap.
want
【在 G****3 的大作中提到】 : I have a problem. The entry in a hashmap has a big cost to create. So I want : to do lazy initialization. But it is in multithreaded enviroment. So I : resolve the issues like doubled checked locking and etc.
|
G****3 发帖数: 11 | 4 I read the code of ConcurrentHashMap. It does work. The get(key) doesn't use
lock for most cases. But it uses volatile to guarantee it can always get
the latest value. Very sophisticated code.
Thanks for the reply! |