Working with Threads

You can start a thread by calling its start() method, which might lead you to believe there’s also a stop() method to bring it to a halt.

Caution

It’s a good idea to heed this deprecation warning. Oracle has deprecated the stop() method because it can cause problems for other threads running in the Java interpreter. The resume() and suspend() methods of the class also are deprecated.

Although Java includes a stop() method in the Thread class, it has been deprecated. In Java, a deprecated element is a class, interface, method, or variable that has been replaced with something that works better.

The next project you undertake shows how you can stop a thread. The program you are writing rotates through a list of website titles ...

Get Sams Teach Yourself Java™ in 24 Hours, Sixth 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.