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

Hi,

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 https://discuss.appium.io) 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

Testng.xml:
Please find the uploaded testng.txt file

Code snippet to start appium server:

String osName = System.getProperty(“os.name”).toLowerCase();
CommandLine command = null;
Process p = null;
if (osName.contains(“windows”) && platformName.equals(“Android”)) {
String currentUser = System.getProperty(“user.name”);
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);
}else{
command = new CommandLine("/Applications/Appium.app/Contents/Resources/node/bin/node");
command.addArgument("/Applications/Appium.app/Contents/Resources/node_modules/appium/bin/main.js", false);
}
command.addArgument("–port", false);
command.addArgument(portNumber);
command.addArgument("-bp", false);
command.addArgument(bootStrap);
DefaultExecuteResultHandler resultHandler = new DefaultExecuteResultHandler();
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(1);
try {
executor.execute(command, resultHandler);
Thread.sleep(5000);
System.out.println(“Appium server started.”);
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}

Thanks in advance.testng.txt (2.2 KB)