Correction: In one of my last newsletters was the answer to
the question:
Why wait(), sleep(), notify(), notifyAll() must be
inside a synchronized block, otherwise it throws
java.lang.IllegalMonitorStateException: current thread not owner.
see newsletter No 175, tip 2, July 22, 2003 or published on the site December
15, 2003.
Harald M. Mueller from Germany corrected me:
"This is not true for sleep(). However, sleep() can throw an
InterruptedException. It is, in many cases, ok to write
try {
Thread.sleep(...);
} catch (InterruptedException ex) {
// empty - ignore the exception
}
THIS IS THE ONLY SITUATION WHERE AN EXCEPTION
MAY BE IGNORED!!! In all other
catch blocks, either
* rethrow an exception
* show the problem in a GUI dialog
* crash the program
Writing an exception to stdout or stderr with ex.printStacktrace() is NOT OK!!
...
Regards Harald M. Mueller Germany "
Thanks for correction. Please always correct me if I am wrong!
--
John
*******************************************
Our older tips: March 22, 2001 - October 21, 2002
READ
HERE
All published and not published on the site tips read
HERE
21 comments | | Score: 0
|