How to run 2 parallel emulators with Cucumber framework(with gradle) in local machine?

am using Kotlin with Cucumber + Gradle combination where my requirement is to run appium tests in multiple emulators. (I cannot open emulator in Hooks as my scenario decides which emulator it has to open) After googling around i find that parallel execution is most favourable with the help of cloud devices and not local emulator. So is there any possibility to run emulators in local parallelly? Is so can please someone help. Its a very urgent requirement.

fun getDriver(version: String, platform: Platform): AppiumDriver {

    var emulator_port: String = TestBase().getParallelExecutionData(version, "port")
    var system_port: String = TestBase().getParallelExecutionData(version, "system_port")
    var adbPort: String = "5037" //TestBase().getParallelExecutionData(version, "adbPort")
    println("emulator_port is $emulator_port")
    println("system_port is $system_port")
    println("adbPort is $adbPort")

    service = startServer()
    println("Service url is ${service.url}")
    println("GET DRIVER")
    when (platform) {
        Platform.IOS -> {
            caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "iOS")
            caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest")
            caps.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 12")
            caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, "14.0")
            caps.setCapability(MobileCapabilityType.APP, "path")
            caps.setCapability("newCommandTimeout", "40")
            driver = IOSDriver(webDriverURL, caps)
        Platform.ANDROID -> {
            caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "android")
            caps.setCapability("automationName", "UiAutomator2")
            caps.setCapability("appium:androidInstallTimeout", 90_000)
            caps.setCapability("udid", "emulator-$emulator_port")
            caps.setCapability("disableSuppressAccessibilityService", true)
            caps.setCapability("adbExecTimeout", 50_000)
            caps.setCapability("androidDeviceReadyTimeout", 50_000)
            caps.setCapability("appium:ignoreHiddenApiPolicyError", "true")
            caps.setCapability("appium:app", SysVar.APK_PATH)
            caps.setCapability("appium:appPackage", "com.webroot.wms")
            caps.setCapability("appium:appActivity", "com.webroot.wsam.core.views.activities.SetupActivity")
            caps.setCapability("systemPort", system_port.toInt())
            caps.setCapability("adbPort", adbPort.toInt())
            caps.setCapability("clearSystemFiles", true)
                driver = AndroidDriver(service.url, caps)
            } catch (e:Exception){
                println("Reattempting to connect to driver")
                service = startServer()
                driver = AndroidDriver(service.url, caps)

            driver.manage().timeouts().implicitlyWait(Constants.SHORT_TIME_OUT, TimeUnit.SECONDS);
            println("driver launched!")
    return driver

Any help on this is much appreciated.

try first start two emulators with command. second start two appium servers and then start each driver using unique appium port and udid.

each appium server should have unique:

    int appiumPort;
    // ios
    // android
    int bootstrapPort;

each driver should have unique:

    int appiumPort;
    // ios
    public int wdaPort;
    int videoPort;
    // android
    int chromePort; (if you working with browser)
    int systemPort;