Please look at this code(taken from Effective Java book)
import java.util.concurrent.TimeUnit; public class Main { private static boolean stopReq; public s
Make stopReq to true, then it will be stopped. You are again setting the stopReq to false, due to that while loop condition is true always and it is in infinite loop.