Section 23.3 Creating and Executing Threads with the Executor Framework

• A Runnable (p. 963) object represents a task that can execute concurrently with other tasks.

• Interface Runnable declares method run (p. 963) in which you place the code that defines the task to perform. The thread executing a Runnable calls method run to perform the task.

• A program will not terminate until its last thread completes execution.

• You cannot predict the order in which threads will be scheduled, even if you know the order in which they were created and started.

• It’s recommended that you use the Executor interface (p. 963) to manage the execution of Runnable objects. An Executor object typically creates and manages a group of threads—called a thread pool ...

Get Java™ How To Program (Early Objects), Tenth Edition 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.