public class SingleFlight extends Object
| Constructor and Description |
|---|
SingleFlight() |
public <V> V execute(Object key, Callable<V> callable) throws Exception
Callable if no other calls for the same key are currently running.
Concurrent calls for the same key result in one caller invoking the Callable and sharing the result
with the other callers.
The result of an invocation is not cached, only concurrent calls share the same result.key - A unique identification of the method call.
The key must be uniquely identifiable by it's Object.hashCode() and Object.equals(Object) methods.callable - The Callable where the result can be obtained from.Callable.Exception - The Exception which was thrown by the Callable.
Alternatively a InterruptedException can be thrown if
the executing Thread was interrupted while waiting for the result.Copyright © 2015. All Rights Reserved.