...
To avoid deadlock, locks should be acquired and released in the same order and synchronization should be limited to where it is absolutely necessary. For instance, to avoid deadlocks in an applet, the paint()
, dispose()
, stop()
, and destroy()
methods should not be synchronized because they are always called and used from dedicated threads.
...