sergAccount

Untitled

Jan 30th, 2021
561
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.app5;
  7.  
  8. /**
  9.  *
  10.  * @author Admin
  11.  */
  12. public class Main {
  13.  
  14.     public static void main(String[] args) {
  15.         // использование прерывания потока выполнения        
  16.         Thread th1 = new Thread(new MyTask());
  17.         th1.start();
  18.         // используем sleep для того чтобы задача выпол-сь некоторое время
  19.         try {
  20.             Thread.sleep(2000);
  21.         } catch (InterruptedException ex) {
  22.             ex.printStackTrace();          
  23.         }
  24.         // используем interrupt для прерывания потока выполнения
  25.         th1.interrupt();
  26.     }
  27. }
  28.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×