Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    public static void interruptThreadAndJoin(Thread thread) {
        thread.interrupt();
        try {
            thread.join();
        } catch (InterruptedException e) { /* Ignore */
        }
    }

    public static void interruptThreadAndJoin(ThreadGroup threadGroup) {
        Thread[] threads = new Thread[threadGroup.activeCount()];
        threadGroup.enumerate(threads);

        for (Thread thread : threads) {
            interruptThreadAndJoin(thread);
        }
    }

    public static void interruptThreadAndJoin(ThreadGroup threadGroup, int activeThreadsCount) {
        Thread[] threads = new Thread[activeThreadsCount];
        threadGroup.enumerate(threads);

        for (Thread thread : threads) {
            interruptThreadAndJoin(thread);
        }
    }
}