This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Description: Concurrent Stack | |
* | |
* @author liuzhengyang | |
* @version 1.0 | |
* @since 2016-04-07 | |
*/ | |
public class ConcurrentStack<E> { | |
private AtomicReference<Node<E>> top = new AtomicReference<>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Computable<A, V> { | |
V compute(A a); | |
} | |
public class Memorizer<A, V> implements Computable<A, V> { | |
private final ConcurrentMap<A, Future<V>> cache = new ConcurrentHashMap<>(); | |
private final Computable<A, V> computable; | |
public Memorizer(Computable<A, V> computable) { | |
this.computable = computable; |
NewerOlder