Skip to content

Commit a5714b2

Browse files
authored
Merge pull request Snailclimb#356 from jinhao11/javaguide-study
Add:wait和sleep的比较中增加wait(long timeout)方法的说明
2 parents 15d7198 + 286c5cb commit a5714b2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

docs/java/Multithread/JavaConcurrencyBasicsCommonInterviewQuestionsSummary.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ Process finished with exit code 0
294294
- 两者最主要的区别在于:**sleep 方法没有释放锁,而 wait 方法释放了锁**
295295
- 两者都可以暂停线程的执行。
296296
- Wait 通常被用于线程间交互/通信,sleep 通常被用于暂停执行。
297-
- wait() 方法被调用后,线程不会自动苏醒,需要别的线程调用同一个对象上的 notify() 或者 notifyAll() 方法。sleep() 方法执行完成后,线程会自动苏醒。
297+
- wait() 方法被调用后,线程不会自动苏醒,需要别的线程调用同一个对象上的 notify() 或者 notifyAll() 方法。sleep() 方法执行完成后,线程会自动苏醒。或者可以使用wait(long timeout)超时后线程会自动苏醒。
298+
298299

299300
## 10. 为什么我们调用 start() 方法时会执行 run() 方法,为什么我们不能直接调用 run() 方法?
300301

0 commit comments

Comments
 (0)