Next-Gen App & Browser
Testing Cloud

Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Next-Gen App & Browser Testing Cloud

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.

Test Your Website on 3000+ Browsers

Get 100 minutes of automation test minutes FREE!!

Test Now...

KaneAI - Testing Assistant

World’s first AI-Native E2E testing agent.

...
ShadowLT Logo

Start your journey with LambdaTest

Get 100 minutes of automation test minutes FREE!!

Signup for free