Java Thread Future runInNewThread(String threadName, Runnable target)

Here you can find the source of runInNewThread(String threadName, Runnable target)

Description

run In New Thread

License

Open Source License

Declaration

public static void runInNewThread(String threadName, Runnable target) throws Throwable 

Method Source Code


//package com.java2s;
// This software is released under the Apache License 2.0.

import java.util.concurrent.*;

public class Main {
    public static void runInNewThread(String threadName, Runnable target) throws Throwable {
        FutureTask<Object> future = new FutureTask<Object>(target, null);
        new Thread(future, threadName).start();
        try {/*from w w w.  j  a  v  a  2s.  c  o m*/
            future.get();
        } catch (ExecutionException e) {
            throw e.getCause();
        }
    }
}

Related

  1. isSuccessful(CompletableFuture f)
  2. nanoTime()
  3. now(Collection> s)
  4. rollback(Object tx)
  5. runIfNotDoneAndGet(RunnableFuture future)
  6. sequence(List> futures)
  7. sequence(List> futures)
  8. sequence(List> futures)
  9. sequence(List> futures)