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 Main3 {
- public static void main(String[] args) {
- MyTask3 task3 = new MyTask3();
- Thread th = new Thread(task3);
- th.start();
- try {
- // даем поработать задаче некоторое время
- TimeUnit.SECONDS.sleep(6);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
- try {
- // даем поработать задаче некоторое время
- TimeUnit.SECONDS.sleep(6);
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- }
- // прерываем
- th.interrupt();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement