Synchronizing native threads with semaphore at Android NDK