Skip to content

Instantly share code, notes, and snippets.

@mikewadhera
Created May 7, 2010 04:20
Show Gist options
  • Save mikewadhera/393048 to your computer and use it in GitHub Desktop.
Save mikewadhera/393048 to your computer and use it in GitHub Desktop.
/** 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;
}
}
}
@arosien
Copy link

arosien commented May 7, 2010

not sure what kind of java this is... how does a user reuse this class to implement a thunk?

@mikewadhera
Copy link
Author

Check out the puzzle near the bottom of https://www.kaching.com/company/jobs

@arosien
Copy link

arosien commented May 7, 2010

ps. i work for kaching :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment