Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) throws InterruptedException {
- final Thread w = new Thread() {
- @Override
- public void run() {
- boolean toExit = false;
- while (!isInterrupted() && !toExit) {
- try {
- Thread.sleep(500);
- System.out.println("Thread.sleep(500);");
- } catch (InterruptedException e) {
- System.err.println(e.getLocalizedMessage());
- toExit = true;
- }
- }
- }
- };
- // w.setDaemon(true);
- w.start();
- long date = new Date().getTime();
- int i = 0;
- Thread.sleep(5000);
- w.interrupt();
- System.err.println("finish all");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement