Many online writing is in creating a thread function call DetachCurrentThread, but recently wrote code framework is not the same as online, the code framework from top to bottom are as follows:
JAVA layer//JAVA functions
-- -- -- -- -- -- -- --
JNI layer//mainly realizes the JAVA and c + + call each other, must be some function
-- -- -- -- -- -- -- --
Layer/c + +/c + + functions, and realized after receiving the data from the Internet, the received data is sent to JAVA layer functions,
JAVA code:
Receive the received data, and displays a
JNI code:
Callback function that is passed to the c + + code for c + + code received function when using the callback function,
In the callback function, use AttachCurrentThread won the JNIENV, then passed to the JAVA
C + + code:
Created a pthread here, and then collect data, after receiving the data, call the callback function in the JNI,
So the question comes, where DetachCurrentThread I call?? Because my thread is created in the bottom layer of c + +, and this is the most of a library to compile,
Please recognize guidance, thank you
CodePudding user response:
Have to answer, look forward to ~ ~ ~