Using background threads at porting

The previous recipe adds a GUI to the ported fusch program with two issues left behind—unresponsiveness of the GUI and no progress update when processing is going on. This recipe discusses how to use a background thread to handle the processing and report the progress to the main UI thread.

Getting ready

The sample program in this recipe is based on the program we developed in previous recipes of this chapter. You should go through them first. In addition, readers are recommended to reading the following recipes in Chapter 2, Java Native Interface:

  • Calling static and instance methods from the native code
  • Caching jfieldID, jmethodID, and reference data to improve performance

How to do it...

The following steps describe ...

Get Android Native Development Kit Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.