How to stop or interrupt a sleeping thread in java.? I have a thread that syncs data and sleeps for 10 minutes in run() method, if i want to stop the sync by stopping the thread when it is sleeping.? How can this be achieved?
Call the interrupt() method on your thread. This will cause the sleep to be cancelled and an InterruptedException will be thrown.