On Thu, 29 Jan 2026 09:12:21 GMT, Alan Bateman <[email protected]> wrote:

>> src/hotspot/share/services/threadService.cpp line 1479:
>> 
>>> 1477:   if (cl._thread_status == JavaThreadStatus::NEW || cl._thread_status 
>>> == JavaThreadStatus::TERMINATED) {
>>> 1478:     return nullptr;
>>> 1479:   }
>> 
>> It is not obvious to me why this is only a possibility now?
>
> ThreadSnapshot.of(Thread) may be invoked with a platform or virtual Thread in 
> any state. It could sample the thread state before calling 
> ThreadSnapshotFactory::get_thread_snapshot. That would allow it to filter out 
> unstarted/NEW threads. It could also filter terminated threads but that would 
> be racy and get_thread_snapshot would still need to handle terminated threads.
> 
> For platform threads, get_thread_snapshot will bail out early if there is no 
> JavaThread. So the effect of the above is to have virtual threads also be 
> filtered out.

Still not clear to me why any new thread is not already filtered out long 
before now; nor why we have not needed this in the past.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/29461#discussion_r2744583241

Reply via email to