Q:

detached thread end of execution

I am currently creating a program which calls native code from within a java environment (NDK).
I have a function that is going to be called a few times from my java code. In this function I create a detached thread that will act as a timer to stop a particular function in my native code.
The code looks like this:
void myNativeFunction(){
    std::thread timerTrial(&FluidMechanics::Impl::endTrial,this);
    timerTrial.detach();
}

void endTrial(){
    //code here
    return ;
}

The thing is that when endTrial returns I was wondering whether my thread was going to be terminated and all resources freed when I return. Indeed myNativeFunction will be called again a couple of times shortly after that so I don't want to mess up my ressources and memory.

A:

Yes. Any thread specific resources will be automatically released when the detached thread returns.
C++11 draft, N3690, § 30.3.1.7, 10, detach()

The thread represented by *this continues execution without the
  calling thread blocking. When detach() returns, *this no longer
  represents the possibly continuing thread of execution. When the
  thread previously represented by *this ends execution, the
  implementation shall release any owned resources.

(emphasis mine).

