0

I'm using JAVA VisualVM to profiling my program and get the following results about threads execution:

enter image description here

I'm not familiar with how JAVA processes multiple threads, and here are my problems:

1.Does the grean bar suggest that the thread was actually running in the corresponding time interval? If it does so, how can it be possible that the number of simultaneously running threads is larger than the number of processors (which is 8 on my laptop)?

2.Is it possible to check on which processor a thread was running?

Thanks a lot!

Li Danyuan
  • 121
  • 8
  • IIRC green means "runnable" which is the state which says: it's *ready* to be running on a CPU and maybe it's actually running. In other words: if a core is available, then it'll actually run, but depends on the OS scheduler. Also: hyperthreading means you'll usually have twice the number of actually running threads than you have cores. – Joachim Sauer May 12 '21 at 13:41
  • Thanks for your answer! If I may ask, what about checking on which processor a thread was running, if it's not possible in VisualVM, is there some other way to do this? – Li Danyuan May 12 '21 at 13:47
  • That would be operating system specific. And unless the operating system provides a way to pin specific threads to specific processors, you should expect it to change ... unpredictably ... depending on system load etcetera. But read this: https://stackoverflow.com/questions/8032372 – Stephen C May 18 '21 at 22:50

1 Answers1

0

Is it possible to check on which processor a thread was running?

Not sure about VisualVM, but you can get OS thread IDs for java threads with jstack utility.
Then you can find out on which processors the threads are running via any method provided by your OS.

vGbg
  • 16