Chapter 1

Programming Threads

IN THIS CHAPTER

check Examining threads

check Creating threads from the Thread class

check Working with the Runnable interface

check Creating threads that cooperate

check Executing threads

check Making methods cooperate

check Using a lock

check Interrupting threads

Remember the guy from the old Ed Sullivan Show who used to spin plates? Somehow, he managed to keep all those plates spinning, running from pole to pole to give each plate a little nudge — just enough to keep it going.

In Java, threads are the equivalent of the spinning-plate guy. Threads let you divide the work of an application into separate pieces, all of which then run simultaneously. The result is a faster and more efficient program, but ...

Get Java All-in-One For Dummies, 5th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.