This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.coroutines.* | |
fun main() { | |
GlobalScope.launch { | |
delay(1000L) | |
println("World!") | |
} | |
println("Hello,") | |
Thread.sleep(2000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlin.concurrent.thread | |
fun main(args: Array<String>) { | |
thread { | |
Thread.sleep(1000L) | |
println("World!") | |
} | |
println("Hello,") | |
Thread.sleep(2000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.coroutines.GlobalScope | |
import kotlinx.coroutines.delay | |
import kotlinx.coroutines.launch | |
fun main(args: Array<String>) { | |
GlobalScope.launch { | |
delay(1000L) | |
println("World!") | |
printThread() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun makeSomething() { | |
// do some stuff | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun makeSomething(argument: Int) : Int { | |
// do some stuff | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
suspend fun makeSomething() { | |
// do some stuff | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun makeLogin(login: String, password: String, callback: (Token) -> Unit) { | |
// request login | |
callback(token) | |
} | |
fun loadMovies(callback: (List<Movie>) -> Unit) { | |
makeLogin("someValue", "someValue") { token -> | |
// request movies with token | |
callback(movies) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
suspend fun makeLogin(login: String, password: String, callback: (Token) -> Unit) { | |
// request login | |
callback(token) | |
} | |
suspend fun loadMovies(callback: (List<Movie>) -> Unit) { | |
makeLogin("someValue", "someValue") { token -> | |
// request movies with token | |
callback(movies) | |
} |
OlderNewer