Synchronizing native threads with conditional variables at Android NDK

The previous recipe discusses how to synchronize threads with mutex. This recipe describes how to use conditional variables.

How to do it...

The following steps will help us create an Android project that demonstrates the usage of pthread conditional variables:

  1. Create an Android application named NativeThreadsCondVar. Set the package name as cookbook.chapter6.nativethreadscondvar. Refer to the Loading native libraries and registering native methods recipe in Chapter 2, Java Native Interface for more detailed instructions.
  2. Right-click on the project NativeThreadsCondVar, select Android Tools | Add Native Support.
  3. Add a Java file named MainActivity.java under the package cookbook.chapter6.nativethreadscondvar ...

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.