In this chapter, we discuss approaches to investigating the execution of apps that leverage multithreaded architectures. Generally, developers find implementing multithreaded architectures one of the most challenging things in app development, and making the app performant brings another dimension of difficulty. The techniques we discuss in this chapter will give you visibility into the execution of such apps, allowing you to more easily identify problems and optimize the app execution.
To properly understand the content of this chapter, you need to know the basics of threading mechanisms in Java, including thread states and synchronization. For a refresher, read appendix D; it won’t give you all the possible knowledge on threads and concurrency in Java (that would need its own bookshelf), but it will give you enough detail to understand this chapter’s discussion.
In this section, we discuss thread locks and how to analyze them to find eventual issues or opportunities to optimize an app’s execution. Thread locks are caused by different thread synchronization approaches, usually implemented to control the flow of events in a multithreaded architecture. Examples include these: