Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CPU Usage and Object.wait

I was profiling my application using JProfiler and as result, in "CPU Views" section it shows that more than 40% of CPU time is spent on Object.wait(). However as far as I know on Object.wait() CPU is not given to the waiting thread.

Could somebody help understand what's going on and why the profiler shows that this much of CPU is spent on Object.wait()?

like image 583
Faramarz Avatar asked Dec 28 '11 14:12

Faramarz


People also ask

Does waiting thread consume CPU?

None. See above, but the CPU overhead used to manage the threads does not change based on the thread context.

What causes high CPU usage in Java?

Peripheral causes of high Java CPU usagebad JVM memory management; poorly configured Java GC; issues more correctly attributable to the software stack; thread synchronization, contention and deadlock issues; and.


1 Answers

The profiler does not know that the CPU is idle while in wait(). All that the profiler knows is that wait() was entered, and several milliseconds later it returned. So, if those milliseconds tend to take up 40% of your execution time, there you have it.

like image 137
Mike Nakis Avatar answered Oct 06 '22 00:10

Mike Nakis