Reputation: 9794
I want to create a C++11 thread that runs indefinitely, after a JNI call has been made. Why does this generate a Fatal Signal?
#include <thread>
static void teste()
{
while(true)
LOGI("IN TEST");
}
JNIEXPORT void Java_blahblah(JNIEnv *javaEnvironment, jobject self)
{
std::thread t(teste);
//t.join(); //I don't want to join it here.
}
I don't need the C++11 thread to call JNI or anything like that.
Upvotes: 1
Views: 314
Reputation: 75669
According to this answer, the destructor of the thread
will call std::terminate
if the thread is still joinable at time of destruction.
If you do not want to join the thread, you can fix this by detaching the thread instead.
std::thread t(teste).detach();
Upvotes: 2