Sleep and check until condition is true

后端 未结 7 2133
借酒劲吻你
借酒劲吻你 2020-12-16 11:39

Is there a library in Java that does the following? A thread should repeatedly sleep for x milliseconds until a condition becomes true or the max t

7条回答
  •  感动是毒
    2020-12-16 12:12

    You should be using a Condition.

    If you would like to have a timeout in addition to the condition, see await(long time, TimeUnit unit)

提交回复
热议问题