attributestore.java
来自「java concurrency in practice 源码. JAVA」· Java 代码 · 共 30 行
JAVA
30 行
package net.jcip.examples;import java.util.*;import java.util.regex.*;import net.jcip.annotations.*;/** * AttributeStore * <p/> * Holding a lock longer than necessary * * @author Brian Goetz and Tim Peierls */@ThreadSafepublic class AttributeStore { @GuardedBy("this") private final Map<String, String> attributes = new HashMap<String, String>(); public synchronized boolean userLocationMatches(String name, String regexp) { String key = "users." + name + ".location"; String location = attributes.get(key); if (location == null) return false; else return Pattern.matches(regexp, location); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?