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 sk.academy.it;
- /**
- * Poznamky a tipy ku skoleniu <b>ThreadJoin</b>
- *
- * @author Miroslav
- * @version 1.0
- * @since 15.10.2012
- * @see <a href="http://www.it-academy.sk">www.it-academy.sk</a>
- */
- public class ThreadJoin implements Runnable {
- public void run() {
- try {
- Thread.sleep(10000);
- } catch (InterruptedException e) {
- }
- }
- public static void main(String[] args) throws InterruptedException {
- Thread podproces = new Thread(new ThreadJoin());
- podproces.start();
- System.out.println(
- "cakam na dokoncenie spusteneho podprocesu 4 sekundy");
- // Cakanie na dokoncenie procesu
- podproces.join(4000);
- // Testujem ci je vlakno aktivne
- if (podproces.isAlive()) {
- System.out.println(
- "cakal som, ale podproces sa este neskoncil");
- } else {
- System.out.println(
- "podproces skoncil vykonavanie svojej cinnosti");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment