CHAPTER 16

Multi-threading

What is a thread? A thread executes a sequence of steps. The code in a method defines a series of actions. A thread executes the statements in a method sequentially. A thread is a sequence of execution. The statements in a method define a sequence of execution. A thread executes statements in a method one by one. Some of the statements being executed result in invocation of another method or constructor.

Every thread has a task, which it is executing. The task for a thread is defined in a method, which it is supposed to finish. What is required by a thread for executing the task (method)? In Java a thread uses a runtime stack to carry out its task. Initially the runtime stack is loaded with the method (frame is created) ...

Get The class of 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.