简体   繁体   English

我可以在多模块多语言(kotlin 和 java)项目应用程序中使用协程吗?

[英]can I use coroutine in a multi module multi language( kotlin and java ) project app?

lets say there is an android project with module a, b and c all written in java.假设有一个 android 项目,其模块 a、b 和 c 全部用 java 编写。 then I add another module, module d in the project.然后我在项目中添加另一个模块,模块 d。 can I still use coroutine internally in module d?我还能在模块 d 内部使用协程吗?

I know I cannot use it in java module, but does coroutine still work in this project even though specific module that use coroutine was pure kotlin我知道我不能在 java 模块中使用它,但是即使使用协程的特定模块是纯 kotlin,协程仍然在这个项目中工作

You can definitely use coroutines in your kotlin class without any problem.您绝对可以在 kotlin class 中毫无问题地使用协程。 The syntax remains the same as any normal kotlin project.语法与任何普通的 kotlin 项目相同。

On top of that, you can even use coroutines in your Java Class by a workaround using this.最重要的是,您甚至可以通过使用此的解决方法在 Java Class 中使用协程。

Implementing Coroutines in Java在 Java 中实现协程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Java代码制作多语言应用程序? - How can I make a multi-language app with the Java code? 如何在多模块 android 项目(kotlin + java)上配置 SonarQube(使用 jacoco)? - How to configure SonarQube (with jacoco) on multi module android project (kotlin + java)? Kotlin 多平台可以使用 Java 还是只能使用 Kotlin? - Kotlin Multi platform can you use Java or only Kotlin? 迁移到Java9 +时,我应该在现有的Maven多模块Web项目中使用Java模块化吗? - Should I use Java modularity into my existing Maven multi module web project when migrating to Java9+? 如何在多模块 Maven 项目中使用以前构建的 jars? - How can I use previously built jars in a multi-module maven project? 如何为Maven多项目添加声纳模块? - How can i add a module to a maven multi-project for sonar? 我无法从多模块 maven 项目加载资源 - I can't load resource from a multi module maven project 如何在多模块Maven SVN项目的另一个模块中正确使用另一个模块的类? - How can I properly use another a module's class in another module in a multi-mod Maven SVN project? 如何对多模块 Spring 应用程序进行 dockerize 处理? - How can I dockerize multi module Spring app? 我可以在kotlin语言中使用公共数学的Java库吗? - Can I use java library of commons math in kotlin language?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM