Following java code to emulate busy and Idle thread and start it.
import java.util.concurrent.*;
import java.lang.*;
public class ThreadTest {
public static void main(String[] args) {
new Thread(new Idle(), "Idle").start();
new Thread(new Busy(), "Busy").start();
}
}
class Idle implements Runnable {
@Override
public void run() {
try {
TimeUnit.HOURS.sleep(1);
} catch (InterruptedException e) {
}
}
}
class Busy implements Runnable {
@Override
public void run() {
while(true) {
"Test".matches("T.*");
}
}
}
Using Processor Explorer to get this busy java processor and get Thread id it cost lots of CPU
see the following screenshot:
Cover to 4044 to Hexadecimal is oxfcc.
Using VistulVM to dump thread and get that thread.
see the following screenshot
In Linux you can use top -H to get Thread information.
That it!
Any question let me know. Thanks