Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to Stop a Thread in Java? Code Example

Tags: thread java
How To Stop A Thread  In Java?  Code  Example
The Thread is one of the important Classes in Java and multithreading is the most widely used feature, but there is no clear way to stop Thread in Java. Earlier there was a stop method that exists in Thread Class but Java deprecated that method citing some safety reasons. By default, a Thread stops when the execution of run() method finishes either normally or due to any Exception. In this article, we will How to Stop Thread in Java by using a boolean State variable or flag.


This post first appeared on Javarevisited: Blog About Java Programmin, please read the originial post: here

Share the post

How to Stop a Thread in Java? Code Example

×

Subscribe to Javarevisited: Blog About Java Programmin

Get updates delivered right to your inbox!

Thank you for your subscription

×