How can you stop a thread in Java ?

Java related questions and answers
deepak singh
Posts: 686
Joined: Fri Sep 30, 2016 4:19 pm

How can you stop a thread in Java ?

Postby deepak singh » Thu Oct 06, 2016 4:20 pm

How can you stop a thread in Java ?

rameshkhd
Posts: 1279
Joined: Sun Aug 28, 2016 10:45 am

Re: How can you stop a thread in Java ?

Postby rameshkhd » Thu Oct 06, 2016 4:20 pm

Ans). First of all , we should create a boolean type variable which stores ‘ false’ . When the user
wants to stop the thread. We should store ‘true’into the variable. The status of the variable is checked
in the run ( ) method and if it is true, the thread executes ‘return’ statement and then stops.


Return to “Java”

Who is online

Users browsing this forum: No registered users and 1 guest