Top Description Fields Constructors Methods
org.testng.internal.thread

public Class ThreadUtil

extends Object
Class Inheritance
Imports
java.util.List, java.util.concurrent.Callable, .ExecutorService, .LinkedBlockingQueue, .ThreadFactory, .TimeUnit, org.testng.collections.Lists, org.testng.internal.IConfiguration, .Utils, org.testng.log4testng.Logger

A helper class to interface TestNG concurrency usage.

Field Summary

Modifier and TypeField and Description
public static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static ExecutorService
createExecutor(IConfiguration config, int threadCount, String threadFactoryName)

public static String
currentThreadInfo()

Returns a readable name of the current executing thread.

public static void
execute(IConfiguration configuration, String name, List<? extends Runnable>
the list of tasks to be run
tasks
,
int
the size of the parallel threads to be used to execute the tasks
threadPoolSize
,
long
a maximum timeout to wait for tasks finalization
timeout
)

Parallel execution of the tasks.

public static boolean

Returns:

true if the current thread was created by TestNG.
isTestNGThread
()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

THREAD_NAMEback to summary
public static final String THREAD_NAME

Constructor Detail

ThreadUtilback to summary
public ThreadUtil()

Method Detail

createExecutorback to summary
public static ExecutorService createExecutor(IConfiguration config, int threadCount, String threadFactoryName)
currentThreadInfoback to summary
public static String currentThreadInfo()

Returns a readable name of the current executing thread.

executeback to summary
public static void execute(IConfiguration configuration, String name, List<? extends Runnable> tasks, int threadPoolSize, long timeout)

Parallel execution of the tasks. The startup is synchronized so this method emulates a load test.

Parameters
tasks:List<? extends Runnable>

the list of tasks to be run

threadPoolSize:int

the size of the parallel threads to be used to execute the tasks

timeout:long

a maximum timeout to wait for tasks finalization

isTestNGThreadback to summary
public static boolean isTestNGThread()
Returns:boolean

true if the current thread was created by TestNG.