SlideShare a Scribd company logo
Overview
Real life situations
Thread dump format
Taking thread dumps
TDA tools
Reading material
Questions
Real life situations
Problems with I/O
Threads maybe blocked or perform slowly during access to I/O resources:
    File system
    Network
    Database

Single or multiple thread dumps may help understading the problem
Problems with
      algorithms
Algorithm complexity is not suited well for the data set size
Algorithm is overusing expensive resources or memory
Algorithm is overusing locks, while it can be implemented in a lock-free manner
Single or multiple thread dumps may help noticing the problem
Problems with
      locks and
    syncronization
No locking (not thread-safe implementations)
Deadlocks (overly syncronised)
Lock contention (overly syncronised)
Lock overhead (too many locks)
Single or multiple thread dumps may explain the situation
Example:
 HashMap gives
 100% CPU load
Usage of not syncronised HashMap in a multi-threaded application
In certain situations it goes into infinite loop
This causes 100% CPU load
The probabilty of entering infinite loop depends on the size of the HashMap
Single thread dump reveals the problem
From Wikipedia:
                   Deadlocks
  “A deadlock is a situation in which two or more competing actions are each waiting
  for the other to finish, and thus neither ever does.
Deadlocks
In real life, deadlocks are pretty rare
CPU usage is usally close to 0
Single thread dump can reveal a deadlock situation
Lock contention
From Wikipedia:

  “This occurs whenever one process or thread attempts to acquire a lock held by
  another process or thread. The more granular the available locks, the less likely one
  process/thread will request a lock held by the other. (For example, locking a row
  rather than the entire table, or locking a cell rather than the entire row.)
Lock contention
The most common problem with multi-threaded applications related to lock
handling
Sometimes easy, sometimes very hard to detect
You can only see one layer at a time
Multiple thread dumps may help to detect lock contention situations
Sporadic
             application
             behaviour
May be related to not thread safe code
May be related to load patterns
May be related to specific data
Threads dumps may or may not help
Thread dump
   format
Formats
Formats differ for various JVM and application server implementations
There is no tool that supports them all
Though format is usually very readble and follows same principles
HotSpot format
Thread states I
http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.State.html

  “A thread can be in one of the following states:

       NEW - A thread that has not yet started is in this state.

       RUNNABLE - A thread executing in the Java virtual machine is in this state.

       BLOCKED - A thread that is blocked waiting for a monitor lock is in this state.
Thread states II
“
WAITING - A thread that is waiting indefinitely for another thread to perform a
particular action is in this state.
TIMED_WAITING - A thread that is waiting for another thread to perform an
action for up to a specified waiting time is in this state.
TERMINATED - A thread that has exited is in this state.
Taking thread
   dumps
How?
jstack
jconsole
jvisualvm
write your own JMX client
use your favorite profiler
Demo
Thread dump
analysis tools
TDA tools
IBM Thread and Monitor Dump analysis
Java Thread Dump Analyzer
Samurai
Thread Dump Analyzer
Thread Dump Viewer
Demo
Book
Questions?
JVM Internals
           Training
Aestas/IT organizes "JVM Internals" training on March 25/26, 2013.

This 2–day course takes the developer on an in-depth tour of the Java Virtual Machine.
Intended for experienced JVM-based programmers, who want to get deeper with the
platform, this course will introduce the major subsystems of the JVM and practical ways
to apply this knowledge in real applications.
Topics I
History of Java and JVM
Specifications
Bytecode
Base components
Detailed architecture
JIT compilation
Garbage collection
Threads
Locks
Classloading
Topics II
Security
Monitoring tools
Java agents
Debugging
Memory analysis
Tuning principles
GC tuning
Responsiveness and throughput
Tuning Options
Registration
Training registration at:

http://aestasit.com/jvm-training-riga-2013

Or by sending e-mail to:

training@aestasit.com
Thanks!

More Related Content

What's hot

Graylog for open stack 3 steps to know why
Graylog for open stack    3 steps to know whyGraylog for open stack    3 steps to know why
Graylog for open stack 3 steps to know why
Vietnam Open Infrastructure User Group
 
Troubleshooting Tools In JDK
Troubleshooting Tools In JDKTroubleshooting Tools In JDK
Troubleshooting Tools In JDK
Poonam Bajaj Parhar
 
Configuring global infrastructure in terraform
Configuring global infrastructure in terraformConfiguring global infrastructure in terraform
Configuring global infrastructure in terraform
SANGGI CHOI
 
Formation Spring Avancé gratuite par Ippon 2014
Formation Spring Avancé gratuite par Ippon 2014Formation Spring Avancé gratuite par Ippon 2014
Formation Spring Avancé gratuite par Ippon 2014
Ippon
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jiayun Zhou
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Haribabu Nandyal Padmanaban
 
Spring boot
Spring bootSpring boot
Spring boot
sdeeg
 
Zabbix 3.2 presentation June 2017
Zabbix 3.2 presentation June 2017Zabbix 3.2 presentation June 2017
Zabbix 3.2 presentation June 2017
Amirhossein Saberi
 
Zabbix
ZabbixZabbix
Zabbix
pundir5
 
Multithreading in-java
Multithreading in-javaMultithreading in-java
Multithreading in-java
aalipalh
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jaran Flaath
 
[오픈소스컨설팅] 아파치톰캣 운영가이드 v1.3
[오픈소스컨설팅] 아파치톰캣 운영가이드 v1.3[오픈소스컨설팅] 아파치톰캣 운영가이드 v1.3
[오픈소스컨설팅] 아파치톰캣 운영가이드 v1.3
Ji-Woong Choi
 
Spring boot
Spring bootSpring boot
Spring boot
Gyanendra Yadav
 
Concurrency in Java
Concurrency in  JavaConcurrency in  Java
Concurrency in Java
Allan Huang
 
Nest.js Introduction
Nest.js IntroductionNest.js Introduction
Nest.js Introduction
Takuya Tejima
 
QEMU Sandboxing for dummies
QEMU Sandboxing for dummiesQEMU Sandboxing for dummies
QEMU Sandboxing for dummies
Eduardo Otubo
 
JMeter Intro
JMeter IntroJMeter Intro
JMeter Intro
Sam Varadarajan
 
Content Storage With Apache Jackrabbit
Content Storage With Apache JackrabbitContent Storage With Apache Jackrabbit
Content Storage With Apache Jackrabbit
Jukka Zitting
 
How to go about testing in React?
How to go about testing in React? How to go about testing in React?
How to go about testing in React?
Lisa Gagarina
 
Introduction to Zabbix - Company, Product, Services and Use Cases
Introduction to Zabbix - Company, Product, Services and Use CasesIntroduction to Zabbix - Company, Product, Services and Use Cases
Introduction to Zabbix - Company, Product, Services and Use Cases
Zabbix
 

What's hot (20)

Graylog for open stack 3 steps to know why
Graylog for open stack    3 steps to know whyGraylog for open stack    3 steps to know why
Graylog for open stack 3 steps to know why
 
Troubleshooting Tools In JDK
Troubleshooting Tools In JDKTroubleshooting Tools In JDK
Troubleshooting Tools In JDK
 
Configuring global infrastructure in terraform
Configuring global infrastructure in terraformConfiguring global infrastructure in terraform
Configuring global infrastructure in terraform
 
Formation Spring Avancé gratuite par Ippon 2014
Formation Spring Avancé gratuite par Ippon 2014Formation Spring Avancé gratuite par Ippon 2014
Formation Spring Avancé gratuite par Ippon 2014
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
Performance Tuning -  Memory leaks, Thread deadlocks, JDK toolsPerformance Tuning -  Memory leaks, Thread deadlocks, JDK tools
Performance Tuning - Memory leaks, Thread deadlocks, JDK tools
 
Spring boot
Spring bootSpring boot
Spring boot
 
Zabbix 3.2 presentation June 2017
Zabbix 3.2 presentation June 2017Zabbix 3.2 presentation June 2017
Zabbix 3.2 presentation June 2017
 
Zabbix
ZabbixZabbix
Zabbix
 
Multithreading in-java
Multithreading in-javaMultithreading in-java
Multithreading in-java
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
[오픈소스컨설팅] 아파치톰캣 운영가이드 v1.3
[오픈소스컨설팅] 아파치톰캣 운영가이드 v1.3[오픈소스컨설팅] 아파치톰캣 운영가이드 v1.3
[오픈소스컨설팅] 아파치톰캣 운영가이드 v1.3
 
Spring boot
Spring bootSpring boot
Spring boot
 
Concurrency in Java
Concurrency in  JavaConcurrency in  Java
Concurrency in Java
 
Nest.js Introduction
Nest.js IntroductionNest.js Introduction
Nest.js Introduction
 
QEMU Sandboxing for dummies
QEMU Sandboxing for dummiesQEMU Sandboxing for dummies
QEMU Sandboxing for dummies
 
JMeter Intro
JMeter IntroJMeter Intro
JMeter Intro
 
Content Storage With Apache Jackrabbit
Content Storage With Apache JackrabbitContent Storage With Apache Jackrabbit
Content Storage With Apache Jackrabbit
 
How to go about testing in React?
How to go about testing in React? How to go about testing in React?
How to go about testing in React?
 
Introduction to Zabbix - Company, Product, Services and Use Cases
Introduction to Zabbix - Company, Product, Services and Use CasesIntroduction to Zabbix - Company, Product, Services and Use Cases
Introduction to Zabbix - Company, Product, Services and Use Cases
 

Viewers also liked

Thread dump troubleshooting
Thread dump troubleshootingThread dump troubleshooting
Thread dump troubleshooting
Jerry Chan
 
Performance Engineering Basics
Performance Engineering BasicsPerformance Engineering Basics
Performance Engineering Basics
Impetus Technologies
 
IDC & Gomez Webinar --Best Practices: Protect Your Online Revenue Through Web...
IDC & Gomez Webinar --Best Practices: Protect Your Online Revenue Through Web...IDC & Gomez Webinar --Best Practices: Protect Your Online Revenue Through Web...
IDC & Gomez Webinar --Best Practices: Protect Your Online Revenue Through Web...
Compuware APM
 
Basic Thread Knowledge
Basic Thread KnowledgeBasic Thread Knowledge
Basic Thread Knowledge
Shipra Roy
 
Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumps
Tier1 App
 
WebSphere Technical University: Top WebSphere Problem Determination Features
WebSphere Technical University: Top WebSphere Problem Determination FeaturesWebSphere Technical University: Top WebSphere Problem Determination Features
WebSphere Technical University: Top WebSphere Problem Determination Features
Chris Bailey
 
An Introduction to Software Performance Engineering
An Introduction to Software Performance EngineeringAn Introduction to Software Performance Engineering
An Introduction to Software Performance Engineering
Correlsense
 
Hp java heap dump analysis Workshop
Hp java heap dump analysis WorkshopHp java heap dump analysis Workshop
Hp java heap dump analysis Workshop
Madhavan Marimuthu
 

Viewers also liked (8)

Thread dump troubleshooting
Thread dump troubleshootingThread dump troubleshooting
Thread dump troubleshooting
 
Performance Engineering Basics
Performance Engineering BasicsPerformance Engineering Basics
Performance Engineering Basics
 
IDC & Gomez Webinar --Best Practices: Protect Your Online Revenue Through Web...
IDC & Gomez Webinar --Best Practices: Protect Your Online Revenue Through Web...IDC & Gomez Webinar --Best Practices: Protect Your Online Revenue Through Web...
IDC & Gomez Webinar --Best Practices: Protect Your Online Revenue Through Web...
 
Basic Thread Knowledge
Basic Thread KnowledgeBasic Thread Knowledge
Basic Thread Knowledge
 
Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumps
 
WebSphere Technical University: Top WebSphere Problem Determination Features
WebSphere Technical University: Top WebSphere Problem Determination FeaturesWebSphere Technical University: Top WebSphere Problem Determination Features
WebSphere Technical University: Top WebSphere Problem Determination Features
 
An Introduction to Software Performance Engineering
An Introduction to Software Performance EngineeringAn Introduction to Software Performance Engineering
An Introduction to Software Performance Engineering
 
Hp java heap dump analysis Workshop
Hp java heap dump analysis WorkshopHp java heap dump analysis Workshop
Hp java heap dump analysis Workshop
 

Similar to Thread Dump Analysis

Multithreading 101
Multithreading 101Multithreading 101
Multithreading 101
Tim Penhey
 
Java
JavaJava
Java multithreading
Java multithreadingJava multithreading
Java multithreading
Mohammed625
 
Java Multithreading
Java MultithreadingJava Multithreading
Java Multithreading
Rajkattamuri
 
Multithreading
MultithreadingMultithreading
Multithreading
F K
 
multithreading
multithreadingmultithreading
multithreading
Rajkattamuri
 
Java
JavaJava
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
JanmejayaPadhiary2
 
Java Multithreading and Concurrency
Java Multithreading and ConcurrencyJava Multithreading and Concurrency
Java Multithreading and Concurrency
Rajesh Ananda Kumar
 
jvm/java - towards lock-free concurrency
jvm/java - towards lock-free concurrencyjvm/java - towards lock-free concurrency
jvm/java - towards lock-free concurrency
Arvind Kalyan
 
Multithreading and concurrency in android
Multithreading and concurrency in androidMultithreading and concurrency in android
Multithreading and concurrency in android
Rakesh Jha
 
Multi threading
Multi threadingMulti threading
Multi threading
gndu
 
Thread priorities in java
Thread priorities in javaThread priorities in java
Thread priorities in java
Ducat India
 
Threading in java - a pragmatic primer
Threading in java - a pragmatic primerThreading in java - a pragmatic primer
Threading in java - a pragmatic primer
SivaRamaSundar Devasubramaniam
 
Slide 7 Thread-1.pptx
Slide 7 Thread-1.pptxSlide 7 Thread-1.pptx
Slide 7 Thread-1.pptx
ajmalhamidi1380
 
Java Threading
Java ThreadingJava Threading
Java Threading
Guillermo Schwarz
 
Java concurrency
Java concurrencyJava concurrency
Java concurrency
Scheidt & Bachmann
 
Here comes the Loom - Ya!vaConf.pdf
Here comes the Loom - Ya!vaConf.pdfHere comes the Loom - Ya!vaConf.pdf
Here comes the Loom - Ya!vaConf.pdf
Krystian Zybała
 
Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007
Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007
Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007
Baruch Sadogursky
 
J threads-pdf
J threads-pdfJ threads-pdf
J threads-pdf
Venketesh Babu
 

Similar to Thread Dump Analysis (20)

Multithreading 101
Multithreading 101Multithreading 101
Multithreading 101
 
Java
JavaJava
Java
 
Java multithreading
Java multithreadingJava multithreading
Java multithreading
 
Java Multithreading
Java MultithreadingJava Multithreading
Java Multithreading
 
Multithreading
MultithreadingMultithreading
Multithreading
 
multithreading
multithreadingmultithreading
multithreading
 
Java
JavaJava
Java
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Java Multithreading and Concurrency
Java Multithreading and ConcurrencyJava Multithreading and Concurrency
Java Multithreading and Concurrency
 
jvm/java - towards lock-free concurrency
jvm/java - towards lock-free concurrencyjvm/java - towards lock-free concurrency
jvm/java - towards lock-free concurrency
 
Multithreading and concurrency in android
Multithreading and concurrency in androidMultithreading and concurrency in android
Multithreading and concurrency in android
 
Multi threading
Multi threadingMulti threading
Multi threading
 
Thread priorities in java
Thread priorities in javaThread priorities in java
Thread priorities in java
 
Threading in java - a pragmatic primer
Threading in java - a pragmatic primerThreading in java - a pragmatic primer
Threading in java - a pragmatic primer
 
Slide 7 Thread-1.pptx
Slide 7 Thread-1.pptxSlide 7 Thread-1.pptx
Slide 7 Thread-1.pptx
 
Java Threading
Java ThreadingJava Threading
Java Threading
 
Java concurrency
Java concurrencyJava concurrency
Java concurrency
 
Here comes the Loom - Ya!vaConf.pdf
Here comes the Loom - Ya!vaConf.pdfHere comes the Loom - Ya!vaConf.pdf
Here comes the Loom - Ya!vaConf.pdf
 
Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007
Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007
Breaking The Clustering Limits @ AlphaCSP JavaEdge 2007
 
J threads-pdf
J threads-pdfJ threads-pdf
J threads-pdf
 

More from Dmitry Buzdin

How Payment Cards Really Work?
How Payment Cards Really Work?How Payment Cards Really Work?
How Payment Cards Really Work?
Dmitry Buzdin
 
Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?
Dmitry Buzdin
 
How to grow your own Microservice?
How to grow your own Microservice?How to grow your own Microservice?
How to grow your own Microservice?
Dmitry Buzdin
 
How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?
Dmitry Buzdin
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows Machines
Dmitry Buzdin
 
Big Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop InfrastructureBig Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop Infrastructure
Dmitry Buzdin
 
JOOQ and Flyway
JOOQ and FlywayJOOQ and Flyway
JOOQ and Flyway
Dmitry Buzdin
 
Developing Useful APIs
Developing Useful APIsDeveloping Useful APIs
Developing Useful APIs
Dmitry Buzdin
 
Whats New in Java 8
Whats New in Java 8Whats New in Java 8
Whats New in Java 8
Dmitry Buzdin
 
Архитектура Ленты на Одноклассниках
Архитектура Ленты на ОдноклассникахАрхитектура Ленты на Одноклассниках
Архитектура Ленты на ОдноклассникахDmitry Buzdin
 
Dart Workshop
Dart WorkshopDart Workshop
Dart Workshop
Dmitry Buzdin
 
Riding Redis @ask.fm
Riding Redis @ask.fmRiding Redis @ask.fm
Riding Redis @ask.fm
Dmitry Buzdin
 
Rubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part IIRubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part IIDmitry Buzdin
 
Rubylight Pattern-Matching Solutions
Rubylight Pattern-Matching SolutionsRubylight Pattern-Matching Solutions
Rubylight Pattern-Matching SolutionsDmitry Buzdin
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
Dmitry Buzdin
 
Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional Programming
Dmitry Buzdin
 
Rubylight programming contest
Rubylight programming contestRubylight programming contest
Rubylight programming contestDmitry Buzdin
 
Continuous Delivery
Continuous Delivery Continuous Delivery
Continuous Delivery
Dmitry Buzdin
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOps
Dmitry Buzdin
 
Pragmatic Java Test Automation
Pragmatic Java Test AutomationPragmatic Java Test Automation
Pragmatic Java Test Automation
Dmitry Buzdin
 

More from Dmitry Buzdin (20)

How Payment Cards Really Work?
How Payment Cards Really Work?How Payment Cards Really Work?
How Payment Cards Really Work?
 
Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?Как построить свой фреймворк для автотестов?
Как построить свой фреймворк для автотестов?
 
How to grow your own Microservice?
How to grow your own Microservice?How to grow your own Microservice?
How to grow your own Microservice?
 
How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows Machines
 
Big Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop InfrastructureBig Data Processing Using Hadoop Infrastructure
Big Data Processing Using Hadoop Infrastructure
 
JOOQ and Flyway
JOOQ and FlywayJOOQ and Flyway
JOOQ and Flyway
 
Developing Useful APIs
Developing Useful APIsDeveloping Useful APIs
Developing Useful APIs
 
Whats New in Java 8
Whats New in Java 8Whats New in Java 8
Whats New in Java 8
 
Архитектура Ленты на Одноклассниках
Архитектура Ленты на ОдноклассникахАрхитектура Ленты на Одноклассниках
Архитектура Ленты на Одноклассниках
 
Dart Workshop
Dart WorkshopDart Workshop
Dart Workshop
 
Riding Redis @ask.fm
Riding Redis @ask.fmRiding Redis @ask.fm
Riding Redis @ask.fm
 
Rubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part IIRubylight JUG Contest Results Part II
Rubylight JUG Contest Results Part II
 
Rubylight Pattern-Matching Solutions
Rubylight Pattern-Matching SolutionsRubylight Pattern-Matching Solutions
Rubylight Pattern-Matching Solutions
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Poor Man's Functional Programming
Poor Man's Functional ProgrammingPoor Man's Functional Programming
Poor Man's Functional Programming
 
Rubylight programming contest
Rubylight programming contestRubylight programming contest
Rubylight programming contest
 
Continuous Delivery
Continuous Delivery Continuous Delivery
Continuous Delivery
 
Introduction to DevOps
Introduction to DevOpsIntroduction to DevOps
Introduction to DevOps
 
Pragmatic Java Test Automation
Pragmatic Java Test AutomationPragmatic Java Test Automation
Pragmatic Java Test Automation
 

Thread Dump Analysis

  • 1. Overview Real life situations Thread dump format Taking thread dumps TDA tools Reading material Questions
  • 3. Problems with I/O Threads maybe blocked or perform slowly during access to I/O resources: File system Network Database Single or multiple thread dumps may help understading the problem
  • 4. Problems with algorithms Algorithm complexity is not suited well for the data set size Algorithm is overusing expensive resources or memory Algorithm is overusing locks, while it can be implemented in a lock-free manner Single or multiple thread dumps may help noticing the problem
  • 5. Problems with locks and syncronization No locking (not thread-safe implementations) Deadlocks (overly syncronised) Lock contention (overly syncronised) Lock overhead (too many locks) Single or multiple thread dumps may explain the situation
  • 6. Example: HashMap gives 100% CPU load Usage of not syncronised HashMap in a multi-threaded application In certain situations it goes into infinite loop This causes 100% CPU load The probabilty of entering infinite loop depends on the size of the HashMap Single thread dump reveals the problem
  • 7. From Wikipedia: Deadlocks “A deadlock is a situation in which two or more competing actions are each waiting for the other to finish, and thus neither ever does.
  • 8. Deadlocks In real life, deadlocks are pretty rare CPU usage is usally close to 0 Single thread dump can reveal a deadlock situation
  • 9. Lock contention From Wikipedia: “This occurs whenever one process or thread attempts to acquire a lock held by another process or thread. The more granular the available locks, the less likely one process/thread will request a lock held by the other. (For example, locking a row rather than the entire table, or locking a cell rather than the entire row.)
  • 10. Lock contention The most common problem with multi-threaded applications related to lock handling Sometimes easy, sometimes very hard to detect You can only see one layer at a time Multiple thread dumps may help to detect lock contention situations
  • 11. Sporadic application behaviour May be related to not thread safe code May be related to load patterns May be related to specific data Threads dumps may or may not help
  • 12. Thread dump format
  • 13. Formats Formats differ for various JVM and application server implementations There is no tool that supports them all Though format is usually very readble and follows same principles
  • 15. Thread states I http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.State.html “A thread can be in one of the following states: NEW - A thread that has not yet started is in this state. RUNNABLE - A thread executing in the Java virtual machine is in this state. BLOCKED - A thread that is blocked waiting for a monitor lock is in this state.
  • 16. Thread states II “ WAITING - A thread that is waiting indefinitely for another thread to perform a particular action is in this state. TIMED_WAITING - A thread that is waiting for another thread to perform an action for up to a specified waiting time is in this state. TERMINATED - A thread that has exited is in this state.
  • 17. Taking thread dumps
  • 18. How? jstack jconsole jvisualvm write your own JMX client use your favorite profiler
  • 19. Demo
  • 21. TDA tools IBM Thread and Monitor Dump analysis Java Thread Dump Analyzer Samurai Thread Dump Analyzer Thread Dump Viewer
  • 22. Demo
  • 23. Book
  • 25. JVM Internals Training Aestas/IT organizes "JVM Internals" training on March 25/26, 2013. This 2–day course takes the developer on an in-depth tour of the Java Virtual Machine. Intended for experienced JVM-based programmers, who want to get deeper with the platform, this course will introduce the major subsystems of the JVM and practical ways to apply this knowledge in real applications.
  • 26. Topics I History of Java and JVM Specifications Bytecode Base components Detailed architecture JIT compilation Garbage collection Threads Locks Classloading
  • 27. Topics II Security Monitoring tools Java agents Debugging Memory analysis Tuning principles GC tuning Responsiveness and throughput Tuning Options