Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Enumeration;
import java.util.Vector;

public class Main {
    private static Vector threads = new Vector();

    /**
     * For testing only - prevent the tests to exit until all thread finished
     */
    public static void waitForBackgroundThreads() {
        Enumeration e = threads.elements();
        while (e.hasMoreElements()) {
            Thread thread = (Thread) e.nextElement();
            if (thread.isAlive()) {
                try {
                    thread.join();
                } catch (InterruptedException ignore) {
                    ignore.printStackTrace();
                }
            }
        }
    }
}