Threads: The Flow of Execution

A thread, as we know, is a flow of execution in a process. When we run a program, there is at least one thread of execution for its process. We can create threads to start additional flows of execution in order to perform additional tasks concurrently. The libraries or framework we use may also start additional threads behind the scenes, depending on their need.

When multiple threads run as part of a single application, or a JVM, we have multiple tasks or operations running concurrently. A concurrent application makes use of multiple threads or concurrent flows of execution.

On a single processor, these concurrent tasks are often multiplexed or multitasked. That is, the processor rapidly switches between the context ...

Get Programming Concurrency on the JVM 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.