`

java main函数为非守护线程(实时线程)

阅读更多

一直认为main为守护线程,google线程相关的资料时,发现有人说main函数是实时线程,特举例证明此结论!

 

	public static void main(String[] args) throws InterruptedException {
	    Thread t = Thread.currentThread();
	    System.out.println("Thread name:"+t.getName());
	    System.out.println("Thread.isDaemon="+t.isDaemon());;
	}

 

运行结果:

Thread name:main

Thread.isDaemon=false

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics