Specification of Thread.yield method is pretty brief:
--------------------------
public static void yield()
Causes the currently executing thread object to temporarily pause and allow other threads to execute.
--------------------------
And it is not clear how this method behave in respect with monitors ownership.
BTW, spec explicitly claims that 'sleep' method does not cause thread to lose monitor ownership.
In this context spec silence about 'Thread.yield' method could be interpreted in following ways:
1. It is up to implementation to determine if monitor ownership is lost or not.
2. Monitor ownership is explicitly lost.
In any case it looks like correct interpretation should be spelled explicitly in spec.
--------------------------
public static void yield()
Causes the currently executing thread object to temporarily pause and allow other threads to execute.
--------------------------
And it is not clear how this method behave in respect with monitors ownership.
BTW, spec explicitly claims that 'sleep' method does not cause thread to lose monitor ownership.
In this context spec silence about 'Thread.yield' method could be interpreted in following ways:
1. It is up to implementation to determine if monitor ownership is lost or not.
2. Monitor ownership is explicitly lost.
In any case it looks like correct interpretation should be spelled explicitly in spec.
- relates to
-
JDK-6416721 (spec thread) Fix Thread.yield() javadoc
- Closed