A program terminates all its activity and exits when one of two things happens:
- All the threads that are not daemon threads terminate.
- Some thread invokes the
exitmethod of classRuntimeor classSystem, and theexitoperation is not forbidden by the security manager.