RFR: 8153133: Thread.dumpStack() can use StackWalker [v2]

Jaikiran Pai jpai at openjdk.java.net
Mon Nov 8 15:50:11 UTC 2021


On Mon, 8 Nov 2021 11:12:25 GMT, Alan Bateman <alanb at 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


More information about the core-libs-dev mailing list