Source Code : Thread sleep and interrupt
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Thread sleep and interrupt

public class SleepInterrupt extends Object implements Runnable {
public void run() {
try {
System.out.println("in run() - sleep for 20 seconds");
Thread.sleep(20000);
System.out.println("in run() - woke up");
} catch (InterruptedException x) {
System.out.println("in run() - interrupted while sleeping");
return;
}
System.out.println("in run() - leaving normally");
}
public static void main(String[] args) {
SleepInterrupt si = new SleepInterrupt();
Thread t = new Thread(si);
t.start();
// Be sure that the new thread gets a chance to
// run for a while.
try {
Thread.sleep(2000);
} catch (InterruptedException x) {
}
System.out.println("in main() - interrupting other thread");
t.interrupt();
System.out.println("in main() - leaving");
}
}
Thank with us