I don't know why it works, because I thought in "laurel.wait(1000);" the wait has to be inside in a synchronized block or synchronized method, but I don't understand why in here is not in this and it works.
And here, the wait has the problem because is not inside in a synchronized block.
[ March 08, 2006: Message edited by: Frederico Benevides ]
In the first program, you are calling the wait method from within a try block which has a corresponding catch block that ignores all checked exceptions. If you add a print statement in the catch block to print out the name of the exception, this is one possible output.
In the second program you are not catching and ignoring any checked exception so you get the IllegalMonitorStateException. [ March 08, 2006: Message edited by: Keith Lynn ]
I have a question about this code example (TwoThreads class). It comes from K&B's book, page 756.
Given the above code which letters will eventually appear somewhere in the output? (choose all that apply.)
A. A B. B C. C D. D E. E F. F G. The answer cannot be reliably determined H. The code does not compile
the answer is:
A, C, D, E, F.
I don't understand why B is not a correct answer, as is it not possible that a InterruptedException (or any other random exception) occurs, therefore B might be printed? Or are these sort of things ignored in the exam. I thought the answer would be G, as it cannot be relibly determined if B will be output or not.
Plus, the book says that on the exam, the number of options for an answer will be given. In this case, does this mean that in the exam they will tell us 5 answers are correct? That would make this question infinitely more obvious.
Thanks for your time Sok
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com