O'Reilly logo

Java, A Beginner’s Guide, 5th Edition by Herbert Schildt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Thread Class and Runnable Interface

Java’s multithreading system is built upon the Thread class and its companion interface, Runnable. Both are packaged in java.lang. Thread encapsulates a thread of execution. To create a new thread, your program will either extend Thread or implement the Runnable interface.

The Thread class defines several methods that help manage threads. Here are some of the more commonly used ones (we will be looking at these more closely as they are used):

Image

All processes have at least one thread of execution, which is usually called the main thread, because it is the one that is executed when your program begins. Thus, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required