Concurrency

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

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

《Java併發結構》:http://ifeve.com/java-concurrency-constructs/編程

《Java併發性和多線程介紹》:http://ifeve.com/java-concurrency-thread-directory/api

《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併發

Joinoracle

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

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.oop

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

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.
相關文章
相關標籤/搜索