CHAPTER 18

MULTI-THREADED PROGRAMMING

So far, we have written many programs. All of them can be termed as single threaded. For last many years, programming languages were producing single-threaded programs. Only recently, multi-threading support has appeared in programming languages. Java is providing an elegant, easy-to-use multi-threading environment to programmers.

Let us first understand what a thread is.

18.1 What are Threads?

When we start running a program, execution begins with method main. Executing of a method means executing statement after statement in sequence. Please note that loops like for and while are considered as a single (may be complex) statement. As CPUs started becoming faster and faster and OS started supporting multi-tasking, ...

Get Programming with Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.