package org.jtheque.utils;

import org.slf4j.LoggerFactory;

/*
 * Copyright JTheque (Baptiste Wicht)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class ThreadUtils {
    private static final int PROCESSORS = Runtime.getRuntime().availableProcessors();

    public static int processors(){
        return PROCESSORS;
    }

    public static void joinAll(Iterable<Thread> threads) {
        for (Thread thread : threads) {
            try {
                thread.join();
            } catch (InterruptedException e) {
                LoggerFactory.getLogger(ThreadUtils.class).error(e.getMessage(), e);
            }
        }
    }
}

@@ -54,16 +54,101 @@
 ctory;%0A%0A
+import java.util.concurrent.ExecutorService;%0Aimport java.util.concurrent.Executors;%0A%0A
 /*%0A * Co
@@ -923,16 +923,216 @@
 %0A    %7D%0A%0A
+    public static void inNewThread(Runnable runnable)%7B%0A        ExecutorService executor = Executors.newSingleThreadExecutor();%0A%0A        executor.submit(runnable);%0A%0A        executor.shutdown();%0A    %7D%0A%0A
     publ

Add method to launch a Runnable in a new thread