On Mon, 8 Nov 2021 11:12:25 GMT, Alan Bateman <al...@openjdk.org> wrote:

> printStackTrace interacts with locking of the streams to avoid garbled output 
> when many threads are printing to standard output output/error at the same 
> time. If we change dumpStack to use StackWalker then it will need to do the 
> same.

Indeed. I have updated the PR to use a lock while writing out to the 
`System.err`.
I had a look at the `printStackTrace()` implementation and it ends up locking 
the `PrintStream` (`System.err`) or `PrintWriter` for the duration of the 
entire stacktrace printing of each stacktrace element. The updated PR thus uses 
`System.err` as the lock to match that semantic.

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

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

Reply via email to