当前位置:网站首页>线程常用的方法
线程常用的方法
2022-07-04 03:50: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()和wait(time)
public final void wait() throws InterruptedException {
wait(0);
}
public final native void wait(long timeout) throws InterruptedException;
边栏推荐
- Katalon framework tests web (XXI) to obtain element attribute assertions
- 潘多拉 IOT 开发板学习(HAL 库)—— 实验6 独立看门狗实验(学习笔记)
- super_ Subclass object memory structure_ Inheritance tree traceability
- Katalon使用script实现查询List大小
- JDBC advanced
- Rhcsa-- day one
- Why is it recommended that technologists write blogs?
- Zlmediakit compilation and webrtc push-pull flow testing
- The new data center helps speed up the construction of a digital economy with data as a key element
- Activiti7 task service - process variables (setvariable and setvariablelocal)
猜你喜欢
SQL语句加强练习(MySQL8.0为例)
2022-07-03:数组里有0和1,一定要翻转一个区间,翻转:0变1,1变0。 请问翻转后可以使得1的个数最多是多少? 来自小红书。3.13笔试。
干货!基于GAN的稀有样本生成
AAAI2022 | Word Embeddings via Causal Inference: Gender Bias Reducing and Semantic Information Preserving
Infiltration practice guest account mimikatz sunflower SQL rights lifting offline decryption
SQL語句加强練習(MySQL8.0為例)
用于TCP协议交互的TCPClientDemo
Mitsubishi M70 macro variable reading Mitsubishi M80 public variable acquisition Mitsubishi CNC variable reading acquisition Mitsubishi CNC remote tool compensation Mitsubishi machine tool online tool
三菱M70宏变量读取三菱M80公共变量采集三菱CNC变量读取采集三菱CNC远程刀补三菱机床在线刀补三菱数控在线测量
JSON string conversion in unity
随机推荐
Third party login initial version
JDBC advanced
Es network layer
Balance between picture performance of unity mobile game performance optimization spectrum and GPU pressure
laravel admin里百度编辑器自定义路径和文件名
Which product is better if you want to go abroad to insure Xinguan?
Tcpclientdemo for TCP protocol interaction
JVM family -- monitoring tools
Typical applications of minimum spanning tree
[PaddleSeg 源码阅读] PaddleSeg Transform 的 Normalize操作
Katalon framework tests web (XXI) to obtain element attribute assertions
Pytest multi process / multi thread execution test case
My opinion on how to effectively telecommute | community essay solicitation
vim正确加区间注释
Package details_ Four access control characters_ Two details of protected
LNK2038 检测到“RuntimeLibrary”的不匹配项: 值“MD_DynamicRelease”不匹配值“MDd_DynamicDebug”(main.obj 中)
Sales management system of lightweight enterprises based on PHP
“软硬皆施”,助力建成新型云计算数据中心
*. No main manifest attribute in jar
【读书会第十三期】视频文件的封装格式