1

I'm using the jvisualvm to monitor the running java program. when I dig into the details of thread cpu usage, I get the following picture. The CPU usage consists of file portions: Running, Sleeping, Wait, Park and Monitor.

I didn't find any official definition about the columns, so I'd like to know what are these columns really mean in java code.

  • Running: time used in executing.
  • Sleeping: Thread.sleep(long) ?
  • Wait: ?
  • Park: LockSupport.park ?
  • Monitor: ?

Thread CPU time usage

Evans Y.
  • 4,209
  • 6
  • 35
  • 43

2 Answers2

3

I made a simple test and found these columns can map to the java code operations:

  • Sleeping: Thread.sleep(..)
  • Wait: Object.wait(..)
  • Park: when you're using new concurrent objects introduce in jdk5+, which may used LockSupport.park.
  • Monitor: when invoke synchronized method/objects

So, wait/park/monitor all means the thread is blocked, but blocked by different reasons.


If a thread is waiting on a socket, the time may be counted on Running.

enter image description here

In this picture, Thread-pool-Bill is Running for most of time, but the truth is it is waiting on a socket for a very long time:

"Thread-pool-Bill" - Thread t@42
   java.lang.Thread.State: RUNNABLE
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    - locked <79f0aad8> (a java.net.SocksSocketImpl)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
Evans Y.
  • 4,209
  • 6
  • 35
  • 43
0
  • Running: Time the thread is running on CPU
  • Sleeping: Time the thread slept due to Thread.sleep(…)
  • Wait: Time the thread waited on a resource (e.g. socket/tty)
  • Park: Time the thread was parked due to LockSupport.park()
  • Monitor: Time the thread was blocked on a monitor (as Evans Y. correctly pointed out, monitors are invoked on synchronized blocks/functions)
llogiq
  • 13,815
  • 8
  • 40
  • 72