当前位置:网站首页>Thread start and priority
Thread start and priority
2022-07-03 00:44:00 【InfoQ】
start() and run() The difference between
public synchronized void start() {
if (threadStatus != 0)
throw new IllegalThreadStateException();
group.add(this);
boolean started = false;
try {
start0();
started = true;
} finally {
try {
if (!started) {
group.threadStartFailed(this);
}
} catch (Throwable ignore) {
// Don't handle any exceptions , If start0 Throw an exception , Then it will be passed to the call stack
}
}
}
if (threadStatus != 0) throw new IllegalThreadStateException();group.add(this);catch (Throwable ignore) { }public class Thread implements Runnable {
......
private Runnable target;
@Override
public void run() {
if (target != null) {
target.run();
}
}
}
Thread priority
public final static int MIN_PRIORITY = 1;
public final static int NORM_PRIORITY = 5;
public final static int MAX_PRIORITY = 10
public final void setPriority(int newPriority) {
ThreadGroup g;
checkAccess();
if (newPriority > MAX_PRIORITY || newPriority < MIN_PRIORITY) {
throw new IllegalArgumentException();
}
if((g = getThreadGroup()) != null) {
if (newPriority > g.getMaxPriority()) {
newPriority = g.getMaxPriority();
}
setPriority0(priority = newPriority);
}
}
if (newPriority > MAX_PRIORITY || newPriority < MIN_PRIORITY) { } if (newPriority > g.getMaxPriority()) { newPriority = g.getMaxPriority();}边栏推荐
- Baidu AI Cloud takes the lead in building a comprehensive and standardized platform for smart cloud
- Solution to the problem of abnormal display of PDF exported Chinese documents of confluence
- Nacos+openfeign error reporting solution
- Program analysis and Optimization - 9 appendix XLA buffer assignment
- kubernetes编写yml简单入门
- node_modules删不掉
- 【雅思阅读】王希伟阅读P2(阅读填空)
- An excellent orm in dotnet circle -- FreeSQL
- University of Oslo: Li Meng | deep reinforcement learning based on swing transformer
- AttributeError: ‘tuple‘ object has no attribute ‘layer‘问题解决
猜你喜欢
随机推荐
ftrace工具的介绍及使用
lex && yacc && bison && flex 配置的問題
Rust所有权(非常重要)
Explain in detail the significance of the contour topology matrix obtained by using the contour detection function findcontours() of OpenCV, and how to draw the contour topology map with the contour t
1.12 - 指令
Cordova plugin device obtains the device information plug-in, which causes Huawei to fail the audit
关于QByteArray存储十六进制 与十六进制互转
UART、RS232、RS485、I2C和SPI的介绍
Helm basic learning
Multi process programming (III): message queue
Andorid gets the system title bar height
leetcode-2280:表示一个折线图的最少线段数
Linux软件:如何安装Redis服务
2022 list of manufacturers of Chinese 3D vision enterprises (guided positioning and sorting scenes)
FAQ | FAQ for building applications for large screen devices
Basic use of shell script
【AutoSAR 六 描述文件】
Vulkan is not a "panacea"“
Preview word documents online
Web2.0的巨头纷纷布局VC,Tiger DAO VC或成抵达Web3捷径








