Note that the garbage collection thread in JVM is a daemon thread, so it is destroyed when all the user threads have ended. Avoiding deprecated methods Deprecated methods are those that are supported for backwards compatibility but may or may not appear in future revisions. Even though the function names may sound tempting, resist the temptation to use them. Debugging threaded programs Some common, unwanted conditions that occur in threaded programs are deadlocks, livelocks, memory corruption, and resource exhaustion. Deadlocks Deadlocks are perhaps the most common problems with multi-threaded programs.
Deadlocks occur when a thread needs a resource for which another thread has the lock.
This situation is usually very difficult to detect. Livelocks A livelock occurs when a thread is so busy accepting new work that it never has a chance to finish any tasks. The thread ultimately overruns the buffers and causes the program to crash. Imagine a secretary who needs to type a letter but is so busy answering the phone that the letter never gets typed. The exasperating problem of memory corruption can be avoided completely with judicious use of the synchronized keyword.