当前位置:网站首页>Common methods of threads
Common methods of threads
2022-07-04 04:17:00 【InfoQ】
join()
public final synchronized void join(long millis) throws InterruptedException {
long base = System.currentTimeMillis();
long now = 0;
if (millis < 0) {
throw new IllegalArgumentException("timeout value is negative");
}
if (millis == 0) {
while (isAlive()) {
wait(0);
}
} else {
while (isAlive()) {
long delay = millis - now;
if (delay <= 0) {
break;
}
wait(delay);
now = System.currentTimeMillis() - base;
}
}
}
if (millis < 0) { throw new IllegalArgumentException("timeout value is negative");}
if (millis == 0) { while (isAlive()) { wait(0); } }
wait(delay);
yield()
public static native void yield();
sleep()
public static native void sleep(long millis) throws InterruptedException;
wait() and wait(time)
public final void wait() throws InterruptedException {
wait(0);
}
public final native void wait(long timeout) throws InterruptedException;
边栏推荐
- 线程常用的方法
- Cesiumjs 2022^ source code interpretation [0] - article directory and source code engineering structure
- Penetration practice - sqlserver empowerment
- Small record of thinking
- Mindmanager2022 efficient and easy to use office mind map MindManager
- Evolution of MySQL database architecture
- 疫情来袭--远程办公之思考|社区征文
- 1289_ Implementation analysis of vtask suspend() interface in FreeRTOS
- The three-year revenue is 3.531 billion, and this Jiangxi old watch is going to IPO
- Katalon framework tests web (XXI) to obtain element attribute assertions
猜你喜欢
Cesiumjs 2022^ source code interpretation [0] - article directory and source code engineering structure
Restore the subtlety of window position
Unity 绘制弹球和台球的运动轨迹
Brief explanation of depth first search (with basic questions)
10 reasons for not choosing to use free virtual hosts
Go 语言入门很简单:Go 实现凯撒密码
leetcode刷题:二叉树08(N叉树的最大深度)
2020 Bioinformatics | TransformerCPI
The maximum expiration time of client secret in azure ad application registration is modified to 2 years
毕业设计:设计秒杀电商系统
随机推荐
A review of reverse reinforcement learning at Virginia Tech (VT)
Flink学习6:编程模型
VIM mapping command
【读书会第十三期】视频文件的封装格式
STM32 external DHT11 display temperature and humidity
AAAI2022 | Word Embeddings via Causal Inference: Gender Bias Reducing and Semantic Information Preserving
如何有效远程办公之我见 | 社区征文
Brief explanation of depth first search (with basic questions)
Calculate the odd sum of 1~n (1~100 as an example)
【愚公系列】2022年7月 Go教学课程 002-Go语言环境安装
[book club issue 13] packaging format of video files
毕业设计:设计秒杀电商系统
JDBC 进阶
02 ls 命令的具体实现
I was tortured by my colleague's null pointer for a long time, and finally learned how to deal with null pointer
指针数组和数组指针
Pytest multi process / multi thread execution test case
leetcode刷题:二叉树09(二叉树的最小深度)
Katalon uses script to query list size
2021 RSC | Drug–target affinity prediction using graph neural network and contact maps