Package jetbrains.buildServer.util
Class ThreadUtil
- java.lang.Object
-
- jetbrains.buildServer.util.ThreadUtil
-
public final class ThreadUtil extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
awaitLatch(java.util.concurrent.CountDownLatch latch)
static void
shutdownGracefully(java.util.concurrent.ExecutorService service, java.lang.String identifier)
Gracefully stops executor tasks: stops executor, then waits for some time, then tries to interrupt running tasks and waits for termination of the executor.static void
shutdownGracefully(java.util.concurrent.ExecutorService service, java.lang.String identifier, long shutdownAwaitTimeout, long shutdownNowAwaitTimeout)
Gracefully stops executor tasks: stops executor, then waits for some time, then tries to interrupt running tasks and waits for termination of the executor.static void
shutdownNowAndWait(java.util.concurrent.ExecutorService service, java.lang.String identifier)
Interrupts executor tasks and waits for executor to finish.static void
sleep(long millis)
Sleeps for the specified time.static java.util.Map<java.util.concurrent.Future,java.lang.Throwable>
waitForTasks(java.util.Collection<java.util.concurrent.Future> futures)
Waits for futures to complete, returns all errors occurred during the waiting.
-
-
-
Method Detail
-
shutdownGracefully
public static void shutdownGracefully(@NotNull java.util.concurrent.ExecutorService service, @NotNull java.lang.String identifier)
Gracefully stops executor tasks: stops executor, then waits for some time, then tries to interrupt running tasks and waits for termination of the executor.- Parameters:
service
- executor to shut downidentifier
- executor identifier to use in log messages
-
shutdownGracefully
public static void shutdownGracefully(@NotNull java.util.concurrent.ExecutorService service, @NotNull java.lang.String identifier, long shutdownAwaitTimeout, long shutdownNowAwaitTimeout)
Gracefully stops executor tasks: stops executor, then waits for some time, then tries to interrupt running tasks and waits for termination of the executor.- Parameters:
service
- executor to shut downidentifier
- executor identifier to use in log messagesshutdownAwaitTimeout
- timeout in milliseconds to wait for the service shutdownshutdownNowAwaitTimeout
- timeout in milliseconds to wait for the service shutdownNow
-
shutdownNowAndWait
public static void shutdownNowAndWait(@NotNull java.util.concurrent.ExecutorService service, @NotNull java.lang.String identifier)
Interrupts executor tasks and waits for executor to finish.- Parameters:
service
- executor to shut downidentifier
- executor identifier to use in log messages
-
waitForTasks
@NotNull public static java.util.Map<java.util.concurrent.Future,java.lang.Throwable> waitForTasks(@NotNull java.util.Collection<java.util.concurrent.Future> futures)
Waits for futures to complete, returns all errors occurred during the waiting.- Parameters:
futures
- futures- Returns:
- map from future to exception, if error occurred during the waiting.
-
sleep
public static void sleep(long millis)
Sleeps for the specified time.Does like the
Thread.sleep(long)
does but doesn't throw exceptions.- Parameters:
millis
- sleeping time in milliseconds.
-
awaitLatch
public static void awaitLatch(java.util.concurrent.CountDownLatch latch)
-
-