The Java™ Tutorials — Concurrency :Joins 插入

The Java™ Tutorials — Concurrency :Joins 插入

原文地址:https://docs.oracle.com/javase/tutorial/essential/concurrency/join.html

关键点

  • join定义:t.join()会引起当前线程暂停执行直到t线程执行完毕
  • join也会抛出InterruptedException
  • 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,

join 方法可以让一个线程等待另一线程的完成。如果t是一个Thread对象,而且为正在执行的对象,

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.

会引起当前线程暂停执行直到t线程执行完毕。join的重载允许开发者指定等待时间。然而,同sleep一样,join的实际等待时间同样依赖于操作系统,所以你不应该假定join的等待时长会精确地等于你所指定的时间。

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

类似sleep,join在响应中断时,会退出并抛出InterruptedException异常。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值