javamultithreadingjvisualvm

Is it possible to check on which processor a thread is running in JAVA?


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!


Solution

  • 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.