Originally posted by Prahlad Joshi:
the main method should be modified in such a manner that the main thread should be the last one to terminate.
That is a different question than what you originally asked and what Jan's answer is useful for.
If you want the JVM to continue running until all threads have finished, you don't have to change anything to your program, because that's already what happens if you run it as it is. Note that in that case the thread that runs the main() method exits, but the JVM doesn't stop running until all threads have stopped.
If you explicitly want the thread that runs the main() method to stop last, then you'll want to call join() on the other threads after starting them in the main() method. See the API documentation of class Thread for exact details of what join() does.