Synchronizing native threads with mutex at Android NDK

This recipe discusses how to use pthread mutex at Android NDK.

How to do it...

The following steps help to create an Android project that demonstrates the usage of pthread mutex:

  1. Create an Android application named NativeThreadsMutex. Set the package name as cookbook.chapter6.nativethreadsmutex. 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 NativeThreadsMutex, select Android Tools | Add Native Support.
  3. Add a Java file named MainActivity.java under the cookbook.chapter6.nativethreadsmutex package. This Java file simply loads the native NativeThreadsMutex library and calls ...

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.