Chapter 9. Threads
Threads allow multiple activities to proceed concurrently in the same program. Multithreaded programming is more difficult than single-threaded programming, so the advice of Item 30 is particularly applicable here: If there is a library class that can save you from doing low-level multithreaded programming, by all means use it. The java.util.Timer
class is one example, and Doug Lea's util.concurrent
package[Lea01] is a whole collection of high-level threading utilities. Even if you use such libraries where applicable, you'll still have to write or maintain multithreaded code from time to time. This chapter contains advice to help you write clear, correct, well-documented multithreaded programs.
Item 48: Synchronize access to ...
Get Effective Java™: Programming Language Guide 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.