New Favourite Little Java 8 Feature
By Adrian Sutton
Pre-Java 8:
ThreadLocal<Foo> foo = new ThreadLocal() {
@Override
protected Foo initialValue() {
return new Foo();
}
};
Post-Java 8:
ThreadLocal<Foo> foo = ThreadLocal.withInitial(Foo::new);
Nice.