Brian Goetz的Java Concurrency实践提供了一个用于并发使用的高效可伸缩缓存的示例.这是该类的代码:
public class Memoizer<A, V> implements Computable<A, V> {
private final ConcurrentMap<A, Future<V>> cache
= new ConcurrentHashMap<A, Future<V>>();
private final Computable<A, V> c;
public Memoizer(Computable<A, V> c) { this.c = c; }
public V compute(final A arg) throws InterruptedException {
while (true) {
Future<V> f = cache.get(arg);
if (f == null) {
Callable<V> eval = new Callable<V>() {
public V call() throws InterruptedException {
return c.compute(arg);
}
};
FutureTask<V> ft = new FutureTask<V>(eval);
f = cache.putIfAbsent(arg, ft);
if …Run Code Online (Sandbox Code Playgroud) 有谁知道如何在Jboss 5.1上配置Activemq?如果是这样,他或她可以向我提供这个例子吗?
非常感谢任何答案!阿加塔