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

io.infinicast.ThreadPool Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
package io.infinicast;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Consumer;

public class ThreadPool {
    private static final ExecutorService sExecutor = Executors.newSingleThreadExecutor();

    public static void QueueUserWorkItem(final Consumer item) {
        sExecutor.execute(
                new Runnable() {
                    @Override
                    public void run() {
                        item.accept(null);
                    }
                });

    }

    public static void sleep(int milliseconds) {
        try {
            Thread.sleep(milliseconds);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}