2013-05-03

Continuations for Android

In simple words using "Continuations" mean you can pause the execution of code and restart at the same point later with all local variables. (You can think of it as "freezing" the stack)

While you can use threads and locks for a similar behavior but you can even persist a continuation and reload it later. While this is not something you need every day it can come handy sometimes.

While other programming languages have built in support for something like this it is not a standard feature of Java.

However there is a small and nice Apache project making this possible with Java:

http://commons.apache.org/sandbox/javaflow/

It comes with an Ant task to do byte code manipulation and a small runtime (one or two classes). Really nice!

I wondered if this could work on Android, too. (Ok - there is no reason why not but I wanted to give it a try)

YES! IT WORKS!

One thing that one should be aware of is that you really need byte code transformation done by an Ant task. While it's no problem to extend Android's ant builds we all need to run code right from Eclipse.

Fortunately there is a simple solution to this: Just create an Ant script doing whatever is needed and add a new "Builder" between "Java Builder" and "Android Package Builder". That's it!


3 comments:

  1. It boasts a much better perception extras Iphone and then in form instead of other people. I'm delighted with my purchase…..Ersatzteile iPhone

    ReplyDelete
  2. Nice fast service, cheaper to order my prescription through United Kingdom meds as will get 3 months offer (84tablets) cheaper than paying three prescription charges since gap solely prescribes a month at a time from the site https://deutschemedz.de. Order and received among several days ne'er had a tangle.

    ReplyDelete
  3. The mixer D50 from m-tec has, as one is used to from the company,Putzmaschinen easy-to-use quick-release systems. With these, components can be changed within a few seconds.

    ReplyDelete