示例代码中的注释说明了delay()是非阻塞的。它应该暂停吗?https://kotlinlang.org/docs/reference/coroutines/basics.html fun main() { delay(1000L) // non-blocking delay for 1 second (default time unit is ms)
println("World!") //
我尝试使用Kotlin Coroutines将数据异步写入Realm数据库,代码如下:
suspend fun write(realmObject): Unit = with(realmDatabase,UI都会完全冻结,甚至按钮状态都不会更新,并且会一直显示单击后的涟漪效果,直到数据库操作完成。当协程结束时,UI返回到正常状态并再次响应。我已经在所有这些调用中记录了Thread.currentThread()输出,并且当前线程值总是Thread[DefaultDispatcher-worker-1,5,