Working with Threads

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

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. Anything that has been deprecated can still be used, but may be removed from the language entirely in a future version.

Watch Out!

It's a good idea to heed this deprecation warning. Sun Microsystems has deprecated the stop() method because it can cause problems for other threads running in the Java interpreter.

The next project you undertake will show how a thread can be stopped. ...

Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH 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.