In this episode, we use POSIX thread to show how to use native code to create a thread.
First, we need to add the function:
private native void posixThreads(int threads,int iteration);
Then enter following command in terminal:
javah -d jni -classpath java com.luxuan.threads.MainActivity
In this way, we can regenerate the header file.
Then we follow the instruction in Pro Android C++ with NDK to modify the code in com.luxuan.threads.MainActivity.cpp.
Finally, we run this app. It will be same result as we describe in the previous article.