Appendix D. Understanding Java threads
In this appendix, we’ll discuss the basics of threads in a Java app. A thread is an independent sequential set of instructions your app runs. Operations on a given thread run concurrently with those on other threads. Modern Java applications often depend on multiple threads, making it inevitable to encounter situations where you need to investigate why certain threads are not behaving as expected or why they struggle to cooperate with other threads. That’s why you’ll find threads in several discussions throughout this book (especially chapters 7 to 9, but also here and there in the first half of the book when we discuss debugging). To properly understand these discussions, you need to know some basics about threads. This appendix teaches you those elements that are essential for understanding other discussions we have throughout the book.