Reputation: 7679
Android's Java and Oracle's Java are slightly different. Is it possible to use the following actors or coroutines
also for Android in order to avoid to use threads and share more code between Android's Java and Oracle's Java? Are there other frameworks available for both Java versions.
Thank you in advance.
Upvotes: 10
Views: 2125
Reputation: 7989
You should try actors from Java version of Akka: http://doc.akka.io/docs/akka/snapshot/java/untyped-actors.html
It allows easy growing of actor topology using best practices (no direct access to actors by Java reference, limiting failures to zones, limiting overload using scheduler zones etc.) - all of them are described in free copy of "Scala in Depth" book: http://typesafe.com/resources/scala-in-depth
Here is example (with demo http://vimeo.com/20303656) of dynamic behavior of actors using Akka FSM on Android: https://github.com/akka/akka/blob/master/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnBecome.scala
Also you can try lightweight actors from Functional Java: https://github.com/functionaljava/functionaljava/blob/master/core/src/main/java/fj/control/parallel/Actor.java
Most minimalistic version of an actor for JVM is here: https://github.com/plokhotnyuk/actors/blob/master/src/test/scala/com/github/gist/viktorklang/Actor.scala (its features described here: How to implement actor model without Akka? )
Upvotes: 4