Concurrency

《Concurrency》:http://docs.oracle.com/javase/tutorial/essential/concurrency/index.html

《Concurrency中文翻译》:http://ifeve.com/oracle-java-concurrency-tutorial/

《Java并发结构》:http://ifeve.com/java-concurrency-constructs/

《Java并发性和多线程介绍》:http://ifeve.com/java-concurrency-thread-directory/

《Java并发编程从入门到精通》:http://ifeve.com/%E3%80%8A-java%E5%B9%B6%E5%8F%91%E7%BC%96%E7%A8%8B%E4%BB%8E%E5%85%A5%E9%97%A8%E5%88%B0%E7%B2%BE%E9%80%9A%E3%80%8B%E7%9B%AE%E5%BD%95%E5%92%8C%E5%BA%8F%E8%A8%80/#more-20914

2016-12-27  17:38:22

Join

The join method allows one thread to wait for the completion of another. If t is a Thread object whose thread is currently executing,

t.join();

causes the current thread to pause execution until t's thread terminates. Overloads of join allow the programmer to specify a waiting period. However, as with sleep, join is dependent on the OS for timing, so you should not assume that join will wait exactly as long as you specify.

Like sleep, join responds to an interrupt by exiting with an InterruptedException.

public final void join()
                throws InterruptedException
Waits for this thread to die.

An invocation of this method behaves in exactly the same way as the invocation

join (0)
Throws:
InterruptedException - if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
public final void join(long millis)
                throws InterruptedException
Waits at most millis milliseconds for this thread to die. A timeout of 0 means to wait forever.

This implementation uses a loop of this.wait calls conditioned on this.isAlive. As a thread terminates the this.notifyAll method is invoked. It is recommended that applications not use wait, notify, or notifyAll on Thread instances.

Parameters:
millis - the time to wait in milliseconds
Throws:
IllegalArgumentException - if the value of millis is negative
InterruptedException - if any thread has interrupted the current thread. The interrupted status of the current thread is cleared when this exception is thrown.
 
 
 
 

转载于:https://www.cnblogs.com/beidoufeng/p/6226782.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值