"pinned" terminology

Cay Horstmann cay.horstmann at gmail.com
Tue Aug 12 15:27:35 UTC 2025


I was asked when specifically a thread is pinned/unpinned. Following https://openjdk.org/jeps/444#Pinning, I had assumed that a thread is pinned when it calls a foreign/native method, or prior to JEP 491, when it enters a synchronized block/method.

On the other hand, there is this sentence in JEP 491: "In particular, if a virtual thread calls native code, either through a native method or the Foreign Function & Memory API, and that native code calls back to Java code that performs a blocking operation or blocks on a monitor, then the virtual thread *will be pinned*."

In the JEP 444 sense, it would have already been pinned when calling the native code, but it seems that in the JEP 491 sense, that only happens upon performing a blocking operation in the callback.

I know the JEPs are not authoritative, but I could find no definition for pinning in the API docs or language spec. And I know it's just terminology--the pinning only matters when performing a blocking operation.

Still, it would be nice to have a consistent terminology. Any suggestions?
  
Cheers,

Cay

-- 

Cay S. Horstmann | https://horstmann.com



More information about the loom-dev mailing list