All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.addc.commons.shutdown.Terminator Maven / Gradle / Ivy

Go to download

The addc-base library supplies classes for creating UUIDs, converting between types, outputting byte arrays with different formats, support for Julian dates, delay generators, parsing properties files and support for I18N.

There is a newer version: 2.6
Show newest version
package com.addc.commons.shutdown;

/**
 * The Terminator supplies a method to terminate a {@link Stoppable} in the
 * background.
 *
 */
public final class Terminator {

    /**
     * The TerminatorThread actually stops the stoppable in the background
     */
    private static class TerminatorThread extends Thread {
        private final Stoppable stoppable;

        /**
         * Create a new TerminatorThread
         * 
         * @param stoppable
         *            The stoppable to terminate
         */
        public TerminatorThread(Stoppable stoppable) {
            super();
            this.stoppable= stoppable;
        }

        @Override
        public void run() {
            stoppable.shutdown();
        }
    }

    /**
     * Terminate the {@link Stoppable} in the background.
     *
     * @param stoppable
     *            the {@link Stoppable} to terminate
     */
    public static void terminate(final Stoppable stoppable) {
        TerminatorThread terminator= new TerminatorThread(stoppable);
        terminator.start();
    }

    private Terminator() {
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy