There are two other important methods that allow threads to cooperate. First is the join() method that allows the current thread to wait until another thread is terminated. Overloaded versions of join() accept the parameters that define how long the thread has to wait before it could do something else.
The setDaemon() method terminates the thread automatically after all the non-daemon threads are terminated. Usually, it is used for background and supporting processes.