Synchronizing native threads with semaphore at Android NDK
We have covered mutex, conditional variables, and reader/writer lock in the previous three recipes. This is the last recipe on threads synchronization at Android NDK, and we will discuss semaphores.
Getting ready...
Readers are expected to read through the previous three recipes, Synchronizing native threads with mutex at Android NDK, Synchronizing native threads with conditional variables at Android NDK, and Synchronizing native threads with reader/writer locks at Android NDK, before this one.
How to do it...
The following steps will help you create an Android project that demonstrates the usage of pthread reader/writer lock:
Create an Android application named
NativeThreadsSemaphore
. Set the package name ascookbook.chapter6.nativethreadssemaphore
. 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 NativeThreadsSemaphore...