On Tue, 3 Feb 2026 11:04:46 GMT, David Holmes <[email protected]> wrote:

>> The proposal is that ThreadSnapshot.of(Thread) can be called with any 
>> platform or virtual Thread in any state. With the update, it eagerly tests 
>> with isAlive so will filter out NEW and already TERMINATED threads. If/when 
>> we change Thread.getStackTrace to use ThreadSnapshot then the isAlive check 
>> can be dropped from Thread.getStackTrace. The underlying implementation in 
>> get_thread_snapshot does not need to deal with the NEW state.
>> 
>> There is no need for ThreadDumper to do any additional filtering. The thread 
>> streams that it consumes filter out Threads that are not alive.
>
>> There is no need for ThreadDumper to do any additional filtering. The thread 
>> streams that it consumes filter out Threads that are not alive.
> 
> Okay that is not at all obvious. But in that case you are never passing a NEW 
> thread to `ThreadSnapshot.of()`. But if that is to be the primary API for 
> getting stacktraces then having it filter on isAlive is reasonable.

The thread stream is documented to be a stream of "live" threads and the 
implementations filter out unstarted or already terminated threads.

If I read your latest message correctly then I think you are agreement with the 
current chnage to test isAlive at the "front door". It means 
get_thread_snapshot is never called with an unstarted/NEW Thread.

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

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

Reply via email to