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:
- Create an Android application named
NativeThreadsMutex
. Set the package name ascookbook.chapter6.nativethreadsmutex
. Refer to the Loading native libraries and registering native methods recipe in Chapter 2, Java Native Interface for more detailed instructions. - Right-click on the project NativeThreadsMutex, select Android Tools | Add Native Support.
- Add a Java file named
MainActivity.java
under thecookbook.chapter6.nativethreadsmutex
package. This Java file simply loads the nativeNativeThreadsMutex
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.