当前位置:网站首页>关于Signal Catcher线程中对线程的理解
关于Signal Catcher线程中对线程的理解
2022-04-21 14:51:00 【InfoQ】
Thread* Thread::Attach(const char* thread_name, bool as_daemon, jobject thread_group,bool create_peer) {
Runtime* runtime = Runtime::Current();
......
Thread* self;
{
MutexLock mu(nullptr, *Locks::runtime_shutdown_lock_);
if (runtime->IsShuttingDownLocked()) {
......
} else {
Runtime::Current()->StartThreadBirth();
self = new Thread(as_daemon); //新建一个Thread对象
bool init_success = self->Init(runtime->GetThreadList(), runtime->GetJavaVM()); //调用init函数
Runtime::Current()->EndThreadBirth();
if (!init_success) {
delete self;
return nullptr;
}
}
}
......
self->InitStringEntryPoints();
CHECK_NE(self->GetState(), kRunnable);
self->SetState(kNative);
......
return self;
}
inline ThreadState Thread::SetState(ThreadState new_state) {
// Cannot use this code to change into Runnable as changing to Runnable should fail if
// old_state_and_flags.suspend_request is true.
DCHECK_NE(new_state, kRunnable);
if (kIsDebugBuild && this != Thread::Current()) {
std::string name;
GetThreadName(name);
LOG(FATAL) << "Thread \"" << name << "\"(" << this << " != Thread::Current()="
<< Thread::Current() << ") changing state to " << new_state;
}
union StateAndFlags old_state_and_flags;
old_state_and_flags.as_int = tls32_.state_and_flags.as_int;
tls32_.state_and_flags.as_struct.state = new_state;
return static_cast<ThreadState>(old_state_and_flags.as_struct.state);
}
enum ThreadState {
// Thread.State JDWP state
kTerminated = 66, // TERMINATED TS_ZOMBIE Thread.run has returned, but Thread* still around
kRunnable, // RUNNABLE TS_RUNNING runnable
kTimedWaiting, // TIMED_WAITING TS_WAIT in Object.wait() with a timeout
kSleeping, // TIMED_WAITING TS_SLEEPING in Thread.sleep()
kBlocked, // BLOCKED TS_MONITOR blocked on a monitor
kWaiting, // WAITING TS_WAIT in Object.wait()
kWaitingForGcToComplete, // WAITING TS_WAIT blocked waiting for GC
kWaitingForCheckPointsToRun, // WAITING TS_WAIT GC waiting for checkpoints to run
kWaitingPerformingGc, // WAITING TS_WAIT performing GC
kWaitingForDebuggerSend, // WAITING TS_WAIT blocked waiting for events to be sent
kWaitingForDebuggerToAttach, // WAITING TS_WAIT blocked waiting for debugger to attach
kWaitingInMainDebuggerLoop, // WAITING TS_WAIT blocking/reading/processing debugger events
kWaitingForDebuggerSuspension, // WAITING TS_WAIT waiting for debugger suspend all
kWaitingForJniOnLoad, // WAITING TS_WAIT waiting for execution of dlopen and JNI on load code
kWaitingForSignalCatcherOutput, // WAITING TS_WAIT waiting for signal catcher IO to complete
kWaitingInMainSignalCatcherLoop, // WAITING TS_WAIT blocking/reading/processing signals
kWaitingForDeoptimization, // WAITING TS_WAIT waiting for deoptimization suspend all
kWaitingForMethodTracingStart, // WAITING TS_WAIT waiting for method tracing to start
kWaitingForVisitObjects, // WAITING TS_WAIT waiting for visiting objects
kWaitingForGetObjectsAllocated, // WAITING TS_WAIT waiting for getting the number of allocated objects
kStarting, // NEW TS_WAIT native thread started, not yet ready to run managed code
kNative, // RUNNABLE TS_RUNNING running in a JNI native method
kSuspended, // RUNNABLE TS_RUNNING suspended by GC or debugger
};
版权声明
本文为[InfoQ]所创,转载请带上原文链接,感谢
https://xie.infoq.cn/article/1d603d71eaeac285d6ee6ee5d
边栏推荐
猜你喜欢

【天梯赛】L2-040 哲哲打游戏 (25 point(s))(模拟)

DABDetr论文解读+核心源码解读

想请问一下如何从数据库中找到软件注册码

or1k启动文件分析

Libmysql.com in vs2019 Lib garbled code

Ali's monthly salary is 15K. The interview is so simple

Script operation es

Legendary server setup tutorial, legendary GM permission command setting tutorial

元宇宙发展现状分析

How to provide CPU branch prediction efficiency at the code level
随机推荐
虫子 偶像稚晖君,向神看齐
2023年北京外国语大学汉语国际教育考研上岸前辈备考经验指导
Lightgbm topic 4: lightgbm model saving under pyspark platform
Reproduction of paper -- Libra r-cnn: rewards balanced learning for object detection
lightGBM专题3:PySpark中的StringIndexer和pipeline功能实现
开发者openshift4使用入门教程 - 16 - 使用init container挂载pinpoint APM监控
Insect idol Zhi Huijun, keep up with God
OpenSea 是如何成为最受欢迎的 NFT 市场的?
Amazon evaluates the autotrophic number. What should sellers do if they want to get a review?
Mysql8.0以上重置初始密码的方法
Vs enterprise code diagram
Mysql 执行流程
Software testing (III) p51-p104 software test case methods and defects
android.database.sqlite.SQLiteException: Can't downgrade database from version 2 to 1
What is the reason for this? Is there anything about MySQL installation
Druid database link problem
【云驻共创】华为云数据库-基础知识
Ali's monthly salary is 15K. The interview is so simple
阿里云云效研发协同服务相关协议条款 |云效
我们还能依赖Play to Earn经济获利多久?