当前位置:网站首页>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();}
边栏推荐
- Multiprocess programming (V): semaphores
- 【AutoSAR 十 IO架构】
- Attributeerror: 'tuple' object has no attribute 'layer' problem solving
- 微信小程序获取某个元素的信息(高、宽等),并将px转换为rpx。
- FAQ | FAQ for building applications for large screen devices
- About the practice topic of screen related to unity screen, unity moves around a certain point inside
- 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
- [shutter] image component (the placeholder | transparent_image transparent image plug-in is loaded into the memory)
- Linux软件:如何安装Redis服务
- There is an unknown problem in inserting data into the database
猜你喜欢
FAQ | FAQ for building applications for large screen devices
logback配置文件
利亚德:Micro LED 产品消费端首先针对 100 英寸以上电视,现阶段进入更小尺寸还有难度
Automated defect analysis in electron microscopic images-论文阅读笔记
Rust所有权(非常重要)
Detailed explanation of pod life cycle
【小程序项目开发-- 京东商城】uni-app之自定义搜索组件(中)-- 搜索建议
Use Jenkins II job
2022中国3D视觉企业(引导定位、分拣场景)厂商名单
Rust ownership (very important)
随机推荐
File operation io-part2
Vulkan并非“灵药“
Graduation summary
NC17059 队列Q
Multiprocess programming (II): Pipeline
[shutter] image component (load network pictures | load static pictures | load local pictures | path | provider plug-in)
Introduction of UART, RS232, RS485, I2C and SPI
MySQL 23 classic interview hanging interviewer
Gan model architecture in mm
数组常用操作方法整理(包含es6)及详细使用
The "2022 China Digital Office Market Research Report" can be downloaded to explain the 176.8 billion yuan market in detail
关于QByteArray存储十六进制 与十六进制互转
lex && yacc && bison && flex 配置的問題
Some introduction and precautions about XML
Free we media essential tools sharing
AEM: Nanlin fan Ben et al. - plant rhizosphere growth promoting bacteria control soybean blight
Wechat applet obtains the information of an element (height, width, etc.) and converts PX to rpx.
How SQLSEVER removes data with duplicate IDS
An excellent orm in dotnet circle -- FreeSQL
【AutoSAR 八 OS】