Search code examples
javabatch-fileclientnio

Run Java NIO client 25k times using a batch file


I want to run my client program 25,000 times. I need to create a batch file for this purpose. I just want to test my server how many connections it will accept without any delays. I am using java. nio. Can anybody help me?

  1. I need to know how to create batch file for running a program.

  2. How to call Batch file using java program.

  3. How to create a batch file which run a java program 25,000 times.

Thanks in advance.


Solution

  • Run 25k times in sequence:

    for /l %%x in (1,1,25000) do (java -cp ... MyClass)
    

    Run 25000 times in parallel:

    for /l %%x in (1,1,25000) do (start "" java -cp ... MyClass)
    

    If you want to limit the parallelism (which you should for such high numbers) then you need a bit more logic. One example is given in this answer.