Concurrency/Parallelism Options For Kotlin?

Been looking at concurrency/parallelism options for Kotlin lately (for desktop and server side development) and was wondering what concurrency/parallelism options are available. My knowledge of concurrency/parallelism is very limited with only knowing about threads, Java streaming API, and the UI/background threading technique (for desktop development).

Is there a good website to visit that properly explains all the different concurrency/parallelism options (only the major ones) in a plain English way?

Can be very confusing to get your head around all the different concurrency/parallelism options, and the general concepts in terms of how they all tie in together.

The set of options available for Kotlin is exactly the same as in Java. Because of that, you won’t find a Kotlin-specific description, but any articles covering Java will apply to Kotlin as well.

1 Like

You also might be interested in Kotlin coroutines which are coming as an experimental feature in Kotlin 1.1. You can read the informal description of their design and use cases here: coroutines-examples/kotlin-coroutines-informal.md at master · Kotlin/coroutines-examples · GitHub

2 Likes

Look at Quasar.

http://blog.paralleluniverse.co/2015/06/04/quasar-kotlin/

I hope that Quasar + Kotlin 1.1 + JVM 1.9 will become a great team.

2 Likes

Don’t forget RxJava. Reactive programming is a powerful way to handle concurrency and parallelism, as well as make programming easier in general.

Very good suggestions coming through on concurrency options. Some thoughts on these options:

  • Quasar - Easy to use API, decent documentation, has some Kotlin APIs, difficult to deploy with the Java Agent requirement, doesn’t have Android support, solely focused on concurrency/parallelism
  • RxJava - Well supported on Android with plenty of articles/videos, very high learning curve, there is a Kotlin version available (RxKotlin), not widely used outside of Android, mainly focussed on event processing
  • Kotlin Coroutines - Builtin support in Kotlin 1.1 (will be experimental), has no default implementation but provides a low level API to implement a high level concurrency model, provides some general performance advantages?, implementations provided (by JetBrains/Kotlin community) for some concurrency models (some are Android specific)
1 Like

One possible option for concurrency is Vert.x which can be used standalone with its Agent concurrency model (known as the Event Bus). Important to note that Vert.x isn’t solely focused on concurrency as it is a toolkit for creating reactive applications for the JVM, and has very good documentation. Kotlin support is in the works (currently synced with the latest stable Vert.x version), and should hopefully be officially supported soon.

1 Like