Posted By:
lang_qiu
Posted On:
Monday, December 1, 2003 08:25 PM
Yes, JNI can help you. You can attach your thread to JVM.
And actually you must do it this way when you try to call java codes from within c/c++ sides.Otherwise, the result is unexpected.
First, when you create your native thread, you need to get JavaVM using env->GetJavaVM( &m_vm );
Then, in your native thread's main(run) method, attach it to jvm using m_vm->AttachCurrentThread(...)
Before your native main method exit, using m_vm->DetachCurrentThread() to Detach the thread from VM