Created
May 7, 2010 04:20
-
-
Save mikewadhera/393048 to your computer and use it in GitHub Desktop.
This file contains hidden or 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; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ps. i work for kaching :)