On Fri, 28 Jan 2022 12:54:37 GMT, David Holmes <dhol...@openjdk.org> wrote:

> How are the thread id's determined such that they can change on each attach?

This is all I could find:

https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/controlling-threads-and-processes

I speculated about it a bit in the following bug comment:

https://bugs.openjdk.java.net/browse/JDK-8280770?focusedCommentId=14472814&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14472814

I assume on each attach it iterates over all the threads in the order created 
and assigns IDs starting at 0. So if some in the middle are deleted, then those 
that come after get a new ID. I noticed the following before and after orders 
when the test fails:

4 11 12 13 14 15 16 17 18 19 20 22 23
1 8 9 10 11 12 13 14 15 16 17 19 20 

In the the 1st list "main" is 4. In the second it is 1.  The order of the 
threads remains the same. Only the threadIDs have changed. So I'm guessing 
whichever threads were 1, 2, and 3 in the first list have exited. These would 
all be non-java threads so they don't show up in the SA list of threads. 
However I have no idea what those 3 exiting threads would be, assuming they are 
all ones created before "main".

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

PR: https://git.openjdk.java.net/jdk/pull/7259

Reply via email to