多线程问题

java中如果主线程关闭(main),那么创建的其它子线程还能运行不?我的例子:
public class t {
public static void main(String[] args) {

    System.out.println("kaishi");
    asd th = new asd();
    th.start();
    System.out.println(System.currentTimeMillis());
    System.out.println("tuichu");
    System.out.println(Thread.currentThread().getName()+System.currentTimeMillis());
    System.exit(0);
}

}

class asd extends Thread {

public void run() {
    while (true) {
        System.out.println(Thread.currentThread().getName()+System.currentTimeMillis());
    }
}

}
结果是kaishi
1214278000531
tuichu
main1214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531
Thread-01214278000531这个能说明主线程关闭后子线程也关闭吗?
[b]问题补充:[/b]
那主线程(main)关闭是不是进程关闭呢?
[b]问题补充:[/b]
既然System.exit(0); 是退出jvm,那怎么退出后还会运行一段时间的新建线程呢?

如果你不加System.exit(0); 这样main会在运行结束后,调用Thread类的private方法Thread.exit()将其自身在ThreadGroup中remove掉,但是其产生的非守护线程任然会继续运行.

但如果这样
[code="java"]
public class t {
public static void main(String[] args) {

System.out.println("kaishi");
asd th = new asd();
th.setDaemon(true);
th.start();
System.out.println(System.currentTimeMillis());
System.out.println("tuichu");
System.out.println(Thread.currentThread().getName()+System.currentTimeMillis());
//System.exit(0);
}

}

class asd extends Thread {

public void run() {
while (true) {
System.out.println(Thread.currentThread().getName()+System.currentTimeMillis());
}
}
}
[/code]
即使不加System.exit(0),在主线程结束后,其守护线程也会随之中止。

System.exit(int)的javadoc是这样描述的:
Terminates the currently running Java Virtual Machine. The argument serves as a status code; by convention, a nonzero status code indicates abnormal termination.
是用来中止虚拟机,所以该程序的所有线程将都会中止

应该是进程关闭后,子线程关闭

Thread有守护线程和非守护线程之分。
守护线程在主线程运行结束后,也会结束运行,而非守护线程不会结束。
线程默认都是非守护线程。可以使用thread.setDeamon方法来设置。

进程关闭应该是这个进程下所有的线程都关闭了。

system.exit(0); 代表退出进程

无论什么线程都退出。

你的意思是输出main1214278000531 日志后还会再在输出Thread-01214278000531日志?

应该在执行System.exit(0)的时间中,子线程中断前,这时候子线程仍然在运行,继续输出一些日志也不奇怪,但线程一旦被程序中止,就不会再运行。线程的调度也会让出一些时间片来跑子线程。这应该都会有时间差。至于jvm实现的具体细节,我也不是很清楚。