Java Reference
In-Depth Information
and scalable result cache for a computationally expensive function. Let's start with the obvi-
ous approach—a simple HashMap —and then look at some of its concurrency disadvantages
and how to fix them.
The Computable<A, V> interface in Listing 5.16 describes a function with input of type
A and result of type V . ExpensiveFunction , which implements Computable , takes a
long time to compute its result; we'd like to create a Computable wrapper that remembers
the results of previous computations and encapsulates the caching process. (This technique is
known as memoization .)
Search WWH ::




Custom Search