[concurrency-interest] Spin Loop Hint support: Draft JEP proposal (original) (raw)

Doug Lea dl at cs.oswego.edu
Thu Oct 8 14:56:28 UTC 2015


On 10/08/2015 07:01 AM, David M. Lloyd wrote:

On 10/08/2015 05:58 AM, Doug Lea wrote:

class Thread { // /** * A hint to the platform that the current thread is momentarily * unable to progress. ... add more guidance ... */ void spinYield();

should be: public static void spinYield();

}

In principle, this would also allow the implementation to do an actual yield on uniprocessors or when the load average is high. Probably not in initial implementation though. Adding a method to class Thread risks name clashes with existing methods introduced in subclasses. So this might need a clunkier name to effectively eliminate the possibility. If the method is static, then the impact of a clashing name should be fairly minimal.

Right. For statics, pretty much the only concern is whether reflective mechanics (Class.getMethod etc) return unexpected entries that would break existing code. The name "spinYield" seems unlikely enough to be a problem though.

-Doug



More information about the core-libs-dev mailing list