语法public boolean isdaemon()
example的中文翻译为:示例class samplethread implements runnable { public void run() { if(thread.currentthread().isdaemon()) system.out.println(thread.currentthread().getname()+" is daemon thread"); else system.out.println(thread.currentthread().getname()+" is user thread"); }}// main classpublic class daemonthreadtest { public static void main(string[] args){ samplethread st = new samplethread(); thread th1 = new thread(st,"thread 1"); thread th2 = new thread(st,"thread 2"); th2.setdaemon(true); // set the thread th2 to daemon. th1.start(); th2.start(); }}
输出thread 1 is user threadthread 2 is daemon thread
以上就是isdaemon()方法在java中的重要性是什么?的详细内容。
