+static void* smx_ctx_java_thread_run(void *data) {
+ smx_ctx_java_t context = (smx_ctx_java_t)data;
+ //Attach the thread to the JVM
+ JNIEnv *env;
+ JavaVM *jvm = get_current_vm();
+ jint error = (*jvm)->AttachCurrentThread(jvm, (void **) &env, NULL);
+ xbt_assert((error == JNI_OK), "The thread could not be attached to the JVM");
+ context->jenv = get_current_thread_env();
+ //Wait for the first scheduling round to happen.
+ xbt_os_sem_acquire(context->begin);
+ //Execution of the "run" method.
+ jmethodID id = jxbt_get_smethod(env, "org/simgrid/msg/Process", "run", "()V");
+ xbt_assert( (id != NULL), "Method not found...");
+ (*env)->CallVoidMethod(env, context->jprocess, id);
+ smx_ctx_java_stop((smx_context_t)context);
+
+ return NULL;
+}
+