Chapter 11: Multithreaded Programming

1. How does Java’s multithreading capability enable you to write more efficient programs?

Multithreading allows you to take advantage of the idle time that is present in nearly all programs. When one thread can’t run, another can. In multicore systems, two or more threads can execute simultaneously.

2. Multithreading is supported by the __________ class and the __________ interface.

Multithreading is supported by the Thread class and the Runnable interface.

3. When creating a runnable object, why might you want to extend Thread rather than implement Runnable?

You will extend Thread when you want to override one or more of Thread’s methods other than run( ).

4. Show how to use join( ) to wait for a thread ...

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.