diff --git a/jnius/jni.pxi b/jnius/jni.pxi index afcd661..4e6c546 100644 --- a/jnius/jni.pxi +++ b/jnius/jni.pxi @@ -401,4 +401,5 @@ cdef extern from "jni.h": ctypedef struct JNIInvokeInterface: jint (*AttachCurrentThread)(JavaVM *, JNIEnv **, void *) + jint (*DetachCurrentThread)(JavaVM *) diff --git a/jnius/jnius.pyx b/jnius/jnius.pyx index 08f619a..dc074ba 100644 --- a/jnius/jnius.pyx +++ b/jnius/jnius.pyx @@ -87,7 +87,7 @@ Python:: __all__ = ('JavaObject', 'JavaClass', 'JavaMethod', 'JavaField', 'MetaJavaClass', 'JavaException', 'cast', 'find_javaclass', - 'PythonJavaClass', 'java_method') + 'PythonJavaClass', 'java_method', 'detach') from libc.stdlib cimport malloc, free from functools import partial diff --git a/jnius/jnius_env.pxi b/jnius/jnius_env.pxi index 84b58ff..336ab0e 100644 --- a/jnius/jnius_env.pxi +++ b/jnius/jnius_env.pxi @@ -19,3 +19,7 @@ cdef JNIEnv *get_jnienv() except NULL: jvm[0].AttachCurrentThread(jvm, &env, NULL) return env + +def detach(): + jvm[0].DetachCurrentThread(jvm) +