java - Reusing Supplier, Function and Consumer objects -
currently using completablefuture port streamsupport library implement chain of asynchronous tasks perform io operations.
as function , supplier objects became bit large taste, wanted move them, resulting in code like
private function<boolean, boolean> getemptybufferfunction() { return new function<boolean, boolean>() { @override public boolean apply(boolean didprecedingsucceed) { /* body */ } } }; while works, curious whether practice re-created each time method called, or if better practice have implementation final objects , re-use them. i.e.
private final function<boolean, boolean> emptybufferfunction = new function<boolean, boolean>() { @override public boolean apply(boolean didprecedingsucceed) { /* body */ } } };
Comments
Post a Comment