当前位置:网站首页>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;
边栏推荐
- EV6 helps the product matrix, and Kia is making efforts in the high-end market. The global sales target in 2022 is 3.15 million?
- 用于TCP协议交互的TCPClientDemo
- 2020 Bioinformatics | TransformerCPI
- pytest多进程/多线程执行测试用例
- 【webrtc】m98 ninja 构建和编译指令
- vim映射命令
- 毕业总结
- 支持首次触发的 Go Ticker
- Objective C attribute keyword
- Penetration practice - sqlserver empowerment
猜你喜欢
Idea modify body color
干货!基于GAN的稀有样本生成
【罗技】m720
ctf-pikachu-XSS
ctf-pikachu-CSRF
拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
SQL語句加强練習(MySQL8.0為例)
Cesiumjs 2022^ source code interpretation [0] - article directory and source code engineering structure
Balance between picture performance of unity mobile game performance optimization spectrum and GPU pressure
mysql数据库的存储
随机推荐
Activiti7 task service - process variables (setvariable and setvariablelocal)
如何远程办公更有效率 | 社区征文
指针数组和数组指针
[Huawei cloud IOT] reading notes, "Internet of things: core technology and security of the Internet of things", Chapter 3 (I)
Objective C attribute keyword
Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
三年进账35.31亿,这个江西老表要IPO了
Rhcsa-- day one
The maximum expiration time of client secret in azure ad application registration is modified to 2 years
Lnk2038 detected a mismatch of "runtimelibrary": the value "md_dynamicrelease" does not match the value "mdd_dynamicdebug" (in main.obj)
Detailed explanation of PPTC self recovery fuse
AAAI2022 | Word Embeddings via Causal Inference: Gender Bias Reducing and Semantic Information Preserving
Spa in SDP
PostgreSQL users cannot create table configurations by themselves
Object oriented -- encapsulation, inheritance, polymorphism
华为云鲲鹏工程师培训(广西大学)
SQL語句加强練習(MySQL8.0為例)
SQL statement strengthening exercise (MySQL 8.0 as an example)
JS实现文字滚动 跑马灯效果
Redis cluster uses Lua script. Lua script can also be used for different slots