diff options
Diffstat (limited to 'runtime/native/java_lang_Thread.cc')
-rw-r--r-- | runtime/native/java_lang_Thread.cc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/runtime/native/java_lang_Thread.cc b/runtime/native/java_lang_Thread.cc index 13edd67b5b..a742e812f7 100644 --- a/runtime/native/java_lang_Thread.cc +++ b/runtime/native/java_lang_Thread.cc @@ -47,6 +47,15 @@ static jboolean Thread_isInterrupted(JNIEnv* env, jobject java_thread) { static void Thread_nativeCreate(JNIEnv* env, jclass, jobject java_thread, jlong stack_size, jboolean daemon) { + // There are sections in the zygote that forbid thread creation. + Runtime* runtime = Runtime::Current(); + if (runtime->IsZygote() && runtime->IsZygoteNoThreadSection()) { + jclass internal_error = env->FindClass("java/lang/InternalError"); + CHECK(internal_error != nullptr); + env->ThrowNew(internal_error, "Cannot create threads in zygote"); + return; + } + Thread::CreateNativeThread(env, java_thread, stack_size, daemon == JNI_TRUE); } |