Parallel-safe lambdas

Alex Buckley Alex.Buckley at Sun.COM
Thu Feb 11 12:01:49 PST 2010


Mark Thornton wrote:
> John Rose wrote:
>>  4. allow unqualified references to uplevel methods if they are "pure" (marked @Pure)
>>   
> A colleague recently suggested that a parameter to one of my methods 
> needed to be marked as @Pure. The parameter was a single method 
> interface, where the method would be called an indeterminate number of 
> times and must return the same value on each occasion without side 
> effects. The usage in this case wasn't necessarily concurrent.

You really want to mark it pure AND idempotent, so the runtime can 
aggressively inline it. You'd be set for parallel execution, for free.

This is not the only dimension in which methods are under-characterized 
in Java, see "Fuzzy Access Modifiers" in 
http://wiki.apidesign.org/wiki/ClarityOfAccessModifiers (e.g. "public 
final" == "callable", "protected final" == "callback").

Alex


More information about the lambda-dev mailing list