一、java线程创建流程
1. 部分调用逻辑
Runtime::AttachCurrentThread(const char* thread_name, bool as_daemon, jobject thread_group, bool create_peer) Runtime::Init(RuntimeArgumentMap&& runtime_options_in) //runtime.cc 备注说"ClassLinker needs an attached thread" Thread::Attach(const char* thread_name, bool as_daemon, jobject thread_peer) Thread::Attach() //4个参数的 Thread::Attach(const char* thread_name, bool as_daemon, PeerAction peer_action) start() //ava/lang/Thread.java Thread_nativeCreate(JNIEnv* env, jclass, jobject java_thread, jlong stack_size, jboolean daemon) //java_lang_Thread.cc Thread::CreateNativeThread(JNIEnv*, jobject, size_t, bool is_daemon) //thread.cc 作为pthread_create()这个函数的参数调用 Thread::CreateCallback(void* arg) //thread.cc Thread::Init(ThreadList*, JavaVMExt*, JNIEnvExt*= nullptr) //thread.cc 两个参数三个参数都行 jni/com_android_internal_os_Zygote.cpp 中有多处调用 SpecializeCommon(JNIEnv* env, uid_t uid,...) //com_android_internal_os_Zygote.cpp JNI调java callPostForkChildHooks(int runtimeFlags, boolean isSystemServer, boolean isZygote, String instructionSet) //Zygote.java postForkChild(int runtimeFlags, boolean isSystemServer, boolean isZygote, String instructionSet) //ZygoteHooks.java ZygoteHooks_nativePostForkChild(env, jclass, ...) //dalvik_system_ZygoteHooks.cc Thread::InitAfterFork() //thread.cc Thread::InitTid() //thread.cc tls32_.tid = ::art::GetTid(); syscall(__NR_gettid); //utils.cc
TODO
标签:daemon,java,thread,Thread,cc,创建,流程,bool,Android From: https://www.cnblogs.com/hellokitty2/p/18150874