Hi,look at code below:
1. public synchronized void someMethod() {
2. //lots of code
3. try {
4. Thread.sleep(500);
5. } catch(InterruptedException e) {
6. //do some things here.
7. }
8. //more and more code here
9. }
Select all correct answers
A.The code causes compiling error--can not call sleep inside synchronized method
B.The
thread sleep at least 500 milliseconds if not interrupted
C.When the thread goes to sleep,it releases the lock on the object
D.The "Sleeping" thread always have the lock on the Object
Answer:C,D
I think C,D is contradictory.
Why C,D is right while B is wrong.