Hello!
As this is my first post here, I want to congratulate you smart people out there for your results in the Certification exams and thank you for always be willing to help noobs like myself!
Now... The question...
Well... While formulating it, I understood what I did wrong: I synchronized on the wrong instance. However, I still don't understand what happens in the following (kind of nonsense) code:
From what I understand from KS&BB's book, a
thread gets out of waiting state if and only if a notify() (on the object it waits for) is performed.
The main thread waits for t, but, surprisingly, gets moving exactly when it should (although there is no visible notify; I searched in Thread class also) and prints the factorial variable.
Is there a call to notify() somewhere in the Thread's automatic treatment? Can you figure out what happens there?
Thanks,
Valentin.