when should i use object.wait()
method and when should i use Thread.sleep()
in java?
In my understanding:
Wait()
is used for inter-thread
communication while sleep()
is used to introduce a pause on execution of current thread, generally.
i am asking in the context of usecases of both the methods.for e:g problems like producer consumer can be solved by wait(), notify().