Note that there are some explanatory texts on larger screens.

plurals
  1. PODifference between thread user time and thread cpu time in Java
    primarykey
    data
    text
    <p>The ThreadMXBean has two methods for retrieving thread time usage:</p> <ul> <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/ThreadMXBean.html#getThreadUserTime%28long%29" rel="nofollow noreferrer">getThreadUserTime</a></li> <li><a href="http://java.sun.com/javase/6/docs/api/java/lang/management/ThreadMXBean.html#getThreadCpuTime%28long%29" rel="nofollow noreferrer">getThreadCpuTime</a></li> </ul> <p>What is the difference between the two?</p> <hr> <p><strong>Update 2</strong>: If I'm able to link to the javadocs, <em>please</em> don't quote them - I've read them already.</p> <p><strong>Update</strong>: here's some code which I tried to use to learn what these times mean, with little success:</p> <pre><code>ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean(); threadMXBean.setThreadContentionMonitoringEnabled(true); long mainThreadId = getMainThreadId(threadMXBean); logTimes("Start", threadMXBean, mainThreadId); URL url = new URL("https://hudson.dev.java.net"); URLConnection connection = url.openConnection(); connection.getContent(); logTimes("After loading", threadMXBean, mainThreadId); </code></pre> <p>and the output is:</p> <pre><code>Start Tue Jun 16 16:13:40 EEST 2009 Cpu time : 80, user time: 60, waited: 0, blocked: 0 After loading Tue Jun 16 16:13:43 EEST 2009 Cpu time : 1,020, user time: 960, waited: 0, blocked: 0 </code></pre> <p>So the difference between cpu and user time increased from 20 to 60 milliseconds. Is that because using a HttpUrlConnection does include some network I/O?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload