Package org.testng.internal.thread
Class ThreadUtil
- java.lang.Object
-
- org.testng.internal.thread.ThreadUtil
-
public class ThreadUtil extends Object
A helper class to interface TestNG concurrency usage.- Author:
-
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ThreadUtil.ThreadFactoryImpl
-
Field Summary
Fields Modifier and Type Field Description static String
THREAD_NAME
-
Constructor Summary
Constructors Constructor Description ThreadUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static IExecutor
createExecutor(int threadCount, String threadFactoryName)
static String
currentThreadInfo()
Returns a readable name of the current executing thread.static void
execute(String name, List<? extends Runnable> tasks, int threadPoolSize, long timeout, boolean triggerAtOnce)
Parallel execution of thetasks
.static boolean
isTestNGThread()
-
-
-
-
Field Detail
-
THREAD_NAME
public static final String THREAD_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
isTestNGThread
public static boolean isTestNGThread()
- Returns:
- true if the current thread was created by TestNG.
-
execute
public static void execute(String name, List<? extends Runnable> tasks, int threadPoolSize, long timeout, boolean triggerAtOnce)
Parallel execution of thetasks
. The startup is synchronized so this method emulates a load test.- Parameters:
tasks
- the list of tasks to be runthreadPoolSize
- the size of the parallel threads to be used to execute the taskstimeout
- a maximum timeout to wait for tasks finalizationtriggerAtOnce
- true if the parallel execution of tasks should be trigger at once
-
currentThreadInfo
public static String currentThreadInfo()
Returns a readable name of the current executing thread.
-
-