Advertisement
sergAccount

Untitled

Mar 21st, 2021
696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 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.app24;
  7.  
  8. import java.util.concurrent.TimeUnit;
  9.  
  10. /**
  11.  *
  12.  * @author Admin
  13.  */
  14. public class Main3 {
  15.        
  16.     public static void main(String[] args) {        
  17.         MyTask3 task3 = new MyTask3();
  18.         Thread th = new Thread(task3);        
  19.         th.start();
  20.         try {
  21.             // даем поработать задаче некоторое время
  22.             TimeUnit.SECONDS.sleep(6);
  23.         } catch (InterruptedException ex) {
  24.             ex.printStackTrace();
  25.         }
  26.         try {
  27.             // даем поработать задаче некоторое время
  28.             TimeUnit.SECONDS.sleep(6);
  29.         } catch (InterruptedException ex) {
  30.             ex.printStackTrace();
  31.         }
  32.         // прерываем
  33.         th.interrupt();
  34.     }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement