Created
May 7, 2010 04:20
-
-
Save mikewadhera/393048 to your computer and use it in GitHub Desktop.
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
/** uses the initialize-on-demand holder class idom. */ | |
public class Thunk { | |
public T get() { | |
return ComputeHolder.result; | |
} | |
private static class ComputeHolder { | |
static final T result = doCompute(); | |
static T doCompute() { | |
T t= // some computation | |
return t; | |
} | |
} | |
} |
Check out the puzzle near the bottom of https://www.kaching.com/company/jobs
ps. i work for kaching :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not sure what kind of java this is... how does a user reuse this class to implement a thunk?