xxxxxxxxxx
#include <thread> // std::thread
void foo()
{
// do stuff...
}
void bar(int x)
{
// do stuff...
}
JNIEXPORT void JNICALL
Java_org_testjni_android_Game_someFunction(JNIEnv * env, jobject obj)
{
std::thread first (foo); // spawn new thread that calls foo()
std::thread second (bar,0); // spawn new thread that calls bar(0)
//main, foo and bar now execute concurrently
// synchronize threads:
first.join(); // pauses until first finishes
second.join(); // pauses until second finishes
}