Code never returns

How come this Java 1.4 code never returns me to the command line? It leaves my command window hung until I type Ctrl-C.

public class StackTraceTest

{

public static int factorial(int n)

{

...

}

public static void main(String[] args)

{

String input = JOptionPane.showInputDialog("Enger n: ");

int n = Integer.parseInt(input);

factorial(n);

System.out.println("Factorial of n: " + n);

return;

}

}

factorial is returning successfully (I know by the printouts).

The program never returns me to the command line. I also know the problem is being caused by the two input lines because if I replace them with:

int n=3;

the program returns correctly.

Thanks for your help.

-Jeff

[802 byte] By [JavaJeffreya] at [2007-10-2 23:35:03]
# 1
By invoking JOptionPane you start a Swing event thread which is a non-deamon thread which runs forever. You program will only exit when there are no non-deamon threads left running so your program will run forever.You will have to do an explicit System.exit(0) to force it to quit.
sabre150a at 2007-7-14 16:17:05 > top of Java-index,Java Essentials,New To Java...
# 2
So I merely do the system exit at the end of main().What is non-deamon please?
JavaJeffreya at 2007-7-14 16:17:05 > top of Java-index,Java Essentials,New To Java...
# 3
> So I merely do the system exit at the end of main().Yes!> > What is non-deamon please? http://www.javaworld.com/javaworld/jw-04-1996/jw-04-threads-p2.html
sabre150a at 2007-7-14 16:17:05 > top of Java-index,Java Essentials,New To Java...