Creating Multiple Threads
The preceding examples have created only one child thread. However, your program can spawn as many threads as it needs. For example, the following program creates three child threads:
Ask the Expert
Q: Why does Java have two ways to create child threads (by extending Thread or implementing Runnable) and which approach is better?
A: The Thread class defines several methods that can be overridden by a derived class. Of ...
Get Java, A Beginner's Guide, 5th Edition, 5th 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.