why the sleep method does not leave the lock and wait method
leave the lock
Answer Posted / amit singh
every class has an object lock but when you used
synchronized block or synchronized method
means to say the when you use synchronized keyword then the
object lock come in an existence without you don't get the
lock on particular object you
must know that wait()
1) what is the purpose of when you call wait on the object
which lock you get when you use synchronized block or method
then particular thread immediate leave the
lock so means to say that wait must to use when you get the
lock on the particular object without
2)its your turns to think that there is any mendotary
to call Thread.sleep() method in synchronized block
so whe there is no relation b/t sleep and Monitor(i'm saying
lock on the object)
why youthink it like that why the sleep() doesn't leave the
lock and wait() leave the lock
3) ther is no realtion between object lock and sleep
amit singh
amitsing2008@gmail.com
| Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
What is gwt in java?
What is meant by pass by reference and pass by value in java?
Can we write lambda without functional interface?
Can a dead thread be started again?
For each of the following program segments,give a big zero
analysis for the running time
1.For (i=0;i Do I need both jdk and jre? What is connection pooling in java? What is static class in java? Why we use beans in java? What is http session in java? What is data encapsulation? What is csrf in java? In a barber shop there are 2 doors. customer come in 1
door, leave in other. minimum # of chairs. barber spend his
life in cutting. always barber can cut 1 customer. few
chairs in the shop. if barber busy customer waits, if
chairs full, customer leave. if no customer, barber sleeps.
treat barber and customer as 2 threads. you can use
Semaphore class with arrive and depart and count as
parameter. What is crud operations in java? Why do we need new date and time api in java se 8?