Java Reference
In-Depth Information
catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println("Thread stopped...");
}
public static void main(String[] args) {
StopSuspendResume t = new StopSuspendResume();
// Start the thread
t.start();
// Sleep for 2 seconds
try {
Thread.sleep(2000);
}
catch (InterruptedException e) {
e.printStackTrace();
}
// Suspend the thread
t.suspendThread();
// Sleep for 2 seconds
try {
Thread.sleep(2000);
}
catch (InterruptedException e) {
e.printStackTrace();
}
// Resume the thread
t.resumeThread();
try {
Thread.sleep(2000);
}
catch (InterruptedException e) {
e.printStackTrace();
}
// Stop the thread
t.stopThread();
}
}
Search WWH ::




Custom Search