Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

13.2 Overview of Threads

A thread is an independent sequential path of execution within a program. Many threads can run concurrently within a program. At runtime, threads in a program exist in a common memory space and can, therefore, share both data and code (i.e., they are lightweight compared to processes). They also share the process running the program.

Every thread in Java is created and controlled by a unique object of the java.lang.Thread class. Often the thread and its associated Thread object are thought of as being synonymous.

Threads make the runtime environment asynchronous, allowing different tasks to be performed concurrently. Using this powerful paradigm in Java centers around understanding the following aspects of multithreaded programming:

  • creating threads and providing the code that gets executed by a thread (see Section 13.4, p. 615)
  • accessing common data and code through synchronization (see Section 13.5, p. 626).
  • transitioning between thread states (see Section 13.6, p. 634).
  • + Share This
  • 🔖 Save To Your Account