package com.glassthought.sandboximport gt.sandbox.util.output.Outimport kotlinx.coroutines.*val out = Out.standard()fun main() = runBlocking { // Start two async operations in parallel val deferredOne = async { fetchDataOne() } val deferredTwo = async { fetchDataTwo() } // Wait for results val resultOne = deferredOne.await() val resultTwo = deferredTwo.await() out.println("Combined result: ${resultOne + resultTwo}")}// Simulated data fetch functionsuspend fun fetchDataOne(): Int { delay(1000) // Simulate a network or heavy computation delay out.println("Fetched data one") return 10}// Another simulated data fetch functionsuspend fun fetchDataTwo(): Int { delay(1500) // Simulate a network or heavy computation delay out.println("Fetched data two") return 20}
Command to reproduce:
gt.sandbox.checkout.commit ffbd344f68e987e4c229 \&& cd "${GT_SANDBOX_REPO}" \&& cmd.run.announce "./gradlew run"