When you write a server (for example, a servlet container), all your main should load and start HTTP listener streams, accept streams, file system scan threads, RMI streams, etc.
After the bootstrap is complete, main no longer required, as everything happens asynchronously. In this case, all significant threads are non-daemons, since they must live according to the main method.
Even in Swing (desktop programming), the only requirement on main is to initialize the main window ( JFrame ). The rest happens in Swing Listening Streams (EDTs) and various background threads.
source share