Summary: Two ways of Thread Creation/ Two of Death






Creating Threads

Thread Deaths

Warning: Unfortunate Deaths

A thread can be killed at any time by calling it stop method. For example,

p1.stop();

The stop method causes a sudden termination of the thread's run method. If the run method performs critical or sensitive calculations, stop may leave the program in an inconsistent or awkward state. Normally, you should not use a thread's stop method but arrange for a gentler termination by setting a condition that causes the run method to exit as was done in the previous examples.