Threads & CPU
Thread dumps, runaway CPU, locks and virtual threads.
- High CPU in a Java process: finding the thread and the code responsible
A step-by-step method to go from a busy Java process to the exact thread and stack frame burning CPU, using top -H, the nid in thread dumps, jcmd, Flight Recorder and the GC log.
- Lock contention in Java: finding the monitor every thread is waiting for
How to recognise lock contention in a JVM service, find the contended monitor or ReentrantLock with thread dumps, ThreadMXBean counters and the jdk.JavaMonitorEnter and jdk.ThreadPark events of Flight Recorder, and the code changes that actually reduce it.
- OutOfMemoryError: unable to create native thread, and the limits behind it
What the JVM's 'unable to create native thread' error really means, the Linux limits that trigger it (ulimit -u, pids.max, systemd TasksMax, threads-max, memory for stacks), how to count a process's threads, and how to find the code that leaks them.
- Reading Java thread dumps: jstack, jcmd Thread.print and what each line means
How to take thread dumps with jcmd, jstack or SIGQUIT, how to read thread states, lock lines and deadlock reports, and how to use a series of dumps to diagnose hangs and slow requests.
- Safepoints and time to safepoint: the JVM pauses your GC log does not show
What a HotSpot safepoint is, which operations need one, why time to safepoint can exceed the GC pause itself, how to measure it with -Xlog:safepoint and JFR, and the usual causes: long loops, page faults on mapped files and CPU starvation.
- Virtual threads in production: JEP 444, pinning and what to monitor
How virtual threads work on top of carrier threads, when they help and when they do not, pinning before and after JDK 24, why they should not be pooled, limiting concurrency with semaphores, and how to observe them with thread dumps and JFR.




