Advertisement
sergAccount

Untitled

Mar 14th, 2021
630
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package com.mycompany.app21;
  7.  
  8. import java.time.LocalTime;
  9.  
  10. /**
  11.  *
  12.  * @author Admin
  13.  */
  14. public class MyLongTask implements Runnable {
  15.    
  16.     public MyLongTask(){
  17.        
  18.     }
  19.     @Override
  20.     public void run() {
  21.         //
  22.         System.out.println("MyLongTask.run>>");
  23.         System.out.println("BEFORE SLEEP..." + LocalTime.now());
  24.         try {
  25.             // используем метод sleep - 2000 - приостанавливаем выполнение на 2с
  26.             Thread.sleep(2000);
  27.         } catch (InterruptedException ex) {
  28.             ex.printStackTrace();
  29.         }
  30.         System.out.println("AFTER SLEEP...");
  31.         System.out.println("AFTER SLEEP..." + LocalTime.now());
  32.         System.out.println("<<");
  33.     }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement