Managing data for native threads at Android NDK

There are several options when we want to preserve thread-wide data across functions, including global variables, argument passing, and thread-specific data key. This recipe discusses all the three options with a focus on thread-specific data key.

Getting ready...

Readers are recommended to read the Creating and terminating native threads at Android NDK recipe and the Synchronizing native threads with mutex at Android NDK recipe in this chapter before this one.

How to do it...

The following steps will help us create an Android project that demonstrates data management at Android NDK:

  1. Create an Android application named NativeThreadsData. Set the package name as cookbook.chapter6.nativethreadsdata. Please ...

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.