Reputation: 71
There is a comment above
public native void unpark(Object thread);
"Unblock the given thread blocked on park, or, if it is not blocked, cause the subsequent call to park not to block. Note: this operation is "unsafe" solely because the caller must somehow ensure that the thread has not been destroyed. Nothing special is usually required to ensure this when called from Java (in which there will ordinarily be a live reference to the thread) but this is not nearly-automatically so when calling from native code."
But why called by native code will bring in a destroyed thread?
Upvotes: 0
Views: 698
Reputation: 98324
The comment is probably outdated. I do not see any calls to Unsafe.unpark
from either JDK or HotSpot natives.
Moreover, LockSupport.unpark
calls Unsafe.unpark
directly. At the same time LockSupport
is public API, so it must be safe.
Upvotes: 1