Continuous Test Orchestration And Execution Platform Online

Perform automated and live-interactive testing on 3000+ real desktop and mobile devices online.

What is the use of @Test(threadPoolSize=x)?

In TestNG, the @Test(threadPoolSize=x) annotation defines the number of threads to be used while running a test method. It instructs TestNG to construct a thread pool to run the test procedure in several threads. The test method's running time will be considerably reduced by using a thread pool.

For example, if you have a test method that requires many threads to be executed for improved performance or to mimic concurrent usage, you may use the @Test(threadPoolSize=6) annotation to run the test method with 6 threads.

Here is a code snippet to understand it better:

 @Test(invocationCount = 6, threadPoolSize = 6)
  public void testThreadPools() {


  System.out.printf("Thread Id : %s%n", Thread.currentThread().getId());
   
  }

We have a dedicated blog for TestNG annotation where you will learn about it with practical examples.

LambdaTest

Test your websites, web-apps, or mobile apps seamlessly with LambdaTest.

Start Free Testing
LambdaTest

Earn resume-worthy Selenium certifications that help you land a top job.

Learn More
LambdaTest

Test your web or mobile apps

Test orchestration and execution cloud of 3000+ browsers and OS

Support

24/7 support

Security

Enterprise grade security

Cloud

Fastest test execution cloud