Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.mycompany.app24;
- import java.util.concurrent.TimeUnit;
- /**
- *
- * @author Admin
- */
- public class MyTask2 implements Runnable {
- @Override
- public void run() {
- System.out.println("MyTask2.run>>");
- // trycatch + tab
- for (int i = 0; i < 10; i++) {
- System.out.println("MyTask2.i=" + i);
- try {
- //Thread.sleep(2000);
- TimeUnit.SECONDS.sleep(2);
- } catch (InterruptedException e) {
- e.printStackTrace();
- // 1) завершаем работу задачи в случае InterruptedException
- // 2) продолжить
- break;
- }
- }
- System.out.println("MyTask2<<");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement