当前位置:网站首页>Understanding of threads in signal catcher threads
Understanding of threads in signal catcher threads
2022-04-22 02:21: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); // Create a new one Thread object
bool init_success = self->Init(runtime->GetThreadList(), runtime->GetJavaVM()); // call init function
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://yzsam.com/2022/04/202204211450583489.html
边栏推荐
- flutter 音乐播放器audioplayer
- 风控产品定额的陷阱都有哪些?
- Interview question: use the program to realize the alternating printing of odd and even numbers from 0 to 100 by two threads
- Xu Yuandong was invited to share "Ltd digital business methodology" at Shanghai Management Technology Forum
- Analysis of header NAT & DHCP protocol
- Use of greendao;
- 68 smart pipe gallery project construction solution
- Tensorflow 2.x(keras)源码详解之第五章:数据预处理
- XSS cross site script attack learning record
- 微软新工具准确率达80%?程序员:我谢谢您
猜你喜欢

【查看已经安装的包和命令是由哪个包提供的】

Detailed explanation of transaction isolation level

信息安全概述

Advanced Android interview answer, full analysis of gradle source code
![[timing] reformer: local sensitive hash (LSH) to achieve efficient transformer paper notes](/img/8a/2214bb4f8595ac2d0871cb2c190f00.png)
[timing] reformer: local sensitive hash (LSH) to achieve efficient transformer paper notes

Introduction to Alibaba's super large-scale Flink cluster operation and maintenance system

error:there‘s no Qt version assigned to project please assign a Qt installation in qt project settin

The night can also be colorful, and the full-color night vision system can be realized by deep learning

Shell基础语法
![[FAQ] Anaconda prompt reports an error. Solving environment: failed](/img/c9/e92a27b4150bcbc5ec1654f75a1b65.png)
[FAQ] Anaconda prompt reports an error. Solving environment: failed
随机推荐
What methods can be used to generate sort scan operators, query SQL parsing to generate ast, and then transform to generate physical execution plan?
The youqilin 22.04 lts version system will be released on April 22, equipped with the new ukui 3.1
DEJA_VU3D - Cesium功能集 之 013-军事标绘系列七:正多边形
Advanced formula 43 of C language: the meaning of function
Shell knowledge: awk
(counting line segment tree) lintcode medium 248 · count the number of numbers smaller than a given integer
Shuttle jump interface
49 pages enterprise digital transformation cases and common tools enterprise digital transformation ideas
Profiteering method of blind box project
uni-list的插件导入及使用方法
A general tool class for adding, deleting, querying and modifying databases based on Hikari connection pool
error:there‘s no Qt version assigned to project please assign a Qt installation in qt project settin
Analysis of header NAT & DHCP protocol
MySQL modifies a field to auto increment
Swoole high performance in memory database use and configuration tutorial
flutter 音乐播放器audioplayer
cv2. What is the custom format of drawcontours()
Advanced C language formula 41: analysis of classical problems of memory operation I
机器学习、深度学习知识点
uniapp处理强制刷新问题