import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking fun main() = runBlocking{ GlobalScope.launch { val mqtt = MqttSubscriber() mqtt.connect() val waitTime = System.getenv("WAITTIME").toLong() ?: 10000L delay(waitTime) val resultMap = mqtt.disconnect() val resultProcessor = ProcessResults() resultProcessor.mapToProcess=resultMap resultProcessor.process() } delay(20000L) }