On 2/19/2013 8:59 AM, Olivier GROSSET-GRANGE wrote:
> As the object of this thread suggests, the problem I encounter is that
> in a minimalist test program, there are "ghost" threads after calling
> DestroyJavaVM().
> The environment is WIN32, JRE/JDK 1.6.0_21, and C++ (Visual Studio
> 2008).
> Under certain circumstances, it prevents some processes from exiting
> (ie: IIS7.5 Application Pool : w3wp.exe).
> May be I'm doing something wrong or I forgot one step,
> Here is the very simple code to reproduce the problem:
> JavaVMOption jvmOptions;
> JavaVMInitArgs vm_args;
> vm_args.version = JNI_VERSION_1_6;
> vm_args.nOptions = 0;
> vm_args.options = &jvmOptions;
> vm_args.ignoreUnrecognized = 1;
>
> // *** 1 thread before JNI_CreateJavaVM() ***
> int retcode = JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
> // *** 9 threads after JNI_CreateJavaVM() ***
> if (NULL != jvm)
> jvm->DestroyJavaVM();
> // *** 6 threads after DestroyJavaVM() ***
> Does someone know how to fix this problem please?
> Is it a known problem ?
It is documented that non-daemon threads will continue to run
after DestroyJavaVM is called.
Do you actually start some Java code that is still running?
Other than that check the DestroyJavaVM method doc - I seem to
recall that it should be called with the jvm as argument.
Arne