Parallel execution of android tests on real devices on Windows and Mac machines


I am trying to conduct parallel execution of android tests using Appium and TestNG on Windows and Mac machines, I created a CommndLine code(suggested in as below mentioned to start appium server programmatically, but it is starting only one Appium server instance, second Appium server instance is not being created, so that I am not able to do parallel execution. Please find the below code snippet for the creation of Appium server and testng.xml I am using. I have been struggling with the issue, Can anyone of you please suggest me to achieve this.
Note: When I was debugging the same code it is working.
Below are the appium version and java client jar are being used

Appium version: 1.6.5
Jar: java-client-4.1.2.jar

Please find the uploaded testng.txt file

Code snippet to start appium server:

String osName = System.getProperty(“”).toLowerCase();
CommandLine command = null;
Process p = null;
if (osName.contains(“windows”) && platformName.equals(“Android”)) {
String currentUser = System.getProperty(“”);
command = new CommandLine(“C:/Users/” + currentUser + “/AppData/Roaming/npm/appium.cmd”);
} else if(osName.contains(“mac”) && platformName.equals(“Android”)){
command = new CommandLine("/usr/local/bin/node");
command.addArgument("/usr/local/bin/appium", false);
command = new CommandLine("/Applications/");
command.addArgument("/Applications/", false);
command.addArgument("–port", false);
command.addArgument("-bp", false);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
try {
executor.execute(command, resultHandler);
System.out.println(“Appium server started.”);
} catch (IOException e) {
} catch (InterruptedException e) {

Thanks in advance.testng.txt (2.2 KB)