android - Kotlin Dispatchers 如何与非挂起函数一起工作
问题描述
我是 kotlin 协程的新手,我需要知道 kotlin 协程调度程序在特定情况下是如何工作的
例如
suspend fun executeDBTransaction(){
withContext(Dispatchers.IO){
executeTransactions()
}
}
fun executeTransactions(){
transaction.beginTransaction()
executeUpdateQuery() // non suspend function
executeDeleteQuery()// non suspend function
executeInsertQuery()// non suspend function
transaction.successful()
}
从上面的例子中我需要知道的是
我在 executeTransactions 方法中执行的所有查询都将在单线程上运行吗?
如果我的 executeUpdateQuery 在线程 IO-1 上运行并在线程 IO-2 上运行 executeDeleteQuery,那么它会导致事务不成功。
谁能帮我这个?
解决方案
推荐阅读
- logstash - ELK 读取和存储 log4j 日志
- git - 如果在用户计算机上签出,则监控代码仓库
- javascript - JS加载内容(Yandex Map)和android webview
- git - 无法将本地 git(在 AWS Ubuntu 上)与远程(在 BitBucket 上)同步
- javascript - 带有 Ionic 的 Google 表格 API
- upgrade - 如何将 splunk 6.1.4 升级到 6.5 有许可证
- android - 我的 RecyclerView ContextMenu 不显示
- c# - 通过 FtpWebRequest 获取文件时丢失换行符
- gnuplot - 如何在gnuplot的一行中做几个键
- python - python脚本,输出重定向信号以将浏览器指向目标登录页面