What is the difference between wait() and sleep()?

Asked 1 years ago, Updated 1 years ago, 131 views

What is the difference between wait() and sleep()

multithreading java sleep wait

2022-09-22 22:35

1 Answers

If you get caught, you have to wake up with notify or notify all in other threads And sleep stops for a certain amount of time. It's a static method, so you can use it without having to use a thread object The wait should only be used within the synchronization block.


2022-09-22 22:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.