RFR: 8372704: ThreadMXBean.getThreadUserTime may return total time

Alan Bateman alanb at openjdk.org
Fri Nov 28 07:40:46 UTC 2025


On Thu, 27 Nov 2025 21:55:10 GMT, Jonas Norlinder <jnorlinder at openjdk.org> wrote:

> getThreadUserTime will return total (system + user) time if called with e.g. ManagementFactory.getThreadMXBean().getThreadUserTime(Thread.currentThread().threadId()).
> 
> The specification for this methods states that only user-level CPU time would ever be returned on success.

Well spotted. We had to make significant changes to this code in JDK 21 with JDK-8303242 and it seems to have crept in then.

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

Marked as reviewed by alanb (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/28545#pullrequestreview-3517789481


More information about the serviceability-dev mailing list