Antonio Aradaza
11/08/2019, 1:38 AMAlowaniak
11/08/2019, 8:47 AMmain
or when using spring some config bean or w/e?)Stephan Schroeder
11/08/2019, 10:17 AMimport kotlinx.coroutines.*
import java.util.concurrent.*
import java.net.URL
fun main() {
GlobalScope.launch {
URL("<http://sensei.notice.me>")
.openStream().close()
}
// rest of the code
}
But if the initial action takes only a short time, why use coroutines at all. simply make it purely sequential. If you don’t want a function to be execute eleswhere you can define it within the main function.
fun main() {
fun senseiNoticeMe() {
URL("<http://sensei.notice.me>")
.openStream().close()
}
senseiNoticeMe()
// rest of the code
}
but if it’s a one-time invocation, why make it a method at all
fun main() {
URL("<http://sensei.notice.me>")
.openStream().close()
// rest of the code
}