From System.exit(int) method documentation:
Terminates the currently running Java Virtual Machine. The argument
serves as a status code; by convention, a nonzero status code
indicates abnormal termination.
If you need to execute something during the time waiting for exit, you could create a control thread, that will just wait for the right time to perform the exit like this:
public class ExitFewMiliseconds {
public static void main(String args[]) {
new Thread(new Runnable() {
public void run() {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.exit(0);
}
}).start();
while (true) {
System.out.println("I'm doing something");
}
}
}
If nothing shall be executing while waiting for exit, you could simply use a Thread.sleep(ms)